smith.james0 Posted October 30, 2006 Share Posted October 30, 2006 HiI can get the start and end dates for a current week number by using mktime [code]$StartOfWeek = date("d",mktime(0,0,0,date("n"),(date("j")-date("w")),date("Y")))."/".date("m",mktime(0,0,0,date("n"),(date("j")-date("w")),date("Y")))."/".date("Y",mktime(0,0,0,date("n"),(date("j")-date("w")),date("Y")));$EndOfWeek = date("d",mktime(23,59,59,date("n"),(date("j")+(6-date("w"))),date("Y")))."/".date("m",mktime(23,59,59,date("n"),(date("j")+(6-date("w"))),date("Y")))."/".date("Y",mktime(23,59,59,date("n"),(date("j")+(6-date("w"))),date("Y")));[/code]The problem is a need to be able to find the start and end date of any week inputted via a form. I have had a good look round the web, but i have been unable to find anything to point me in the right direction. Can anyone help?Thanks James Link to comment https://forums.phpfreaks.com/topic/25624-converting-week-number-to-start-and-end-date-of-the-week/ Share on other sites More sharing options...
Barand Posted October 30, 2006 Share Posted October 30, 2006 try[code]<?php// assuming wk1 contains Jan 1st$wk = 44;$day1 = mktime (0,0,0,1,1,date('Y'));$days = ($wk - 1) * 7;$d = strtotime ("+$days days", $day1);$dow = date('w', $d);$sunday = strtotime ("-$dow days", $d);$saturday = strtotime ("+6 days", $sunday);echo date ('D jS F, Y', $sunday). ' to ' . date ('D jS F, Y', $saturday) ;?>[/code] Link to comment https://forums.phpfreaks.com/topic/25624-converting-week-number-to-start-and-end-date-of-the-week/#findComment-116965 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.