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 Quote Link to comment 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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.