Jump to content


This topic is now archived and is closed to further replies.


Converting week number to start and end date of the week

Recommended Posts

I 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")));

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

Share this post

Link to post
Share on other sites
// 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) ;


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.