RE: [PHP] 1st day of the Week

From: Date: Wed, 20 Oct 2004 11:09:47 +0000
Subject: RE: [PHP] 1st day of the Week
Groups: php.general 
Request: Send a blank email to php-general+get-199866@lists.php.net to get a copy of this message
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm > -----Original Message----- > From: Shaun [mailto:shaunthornburgh@hotmail.com] > Sent: 20 October 2004 11:35 > > I am trying to use the strtotime function to get dates for > the first and > last days of a given week: > > <?php > echo date("Y-m-d", strtotime("last monday", > strtotime("2004-10-18"))).'<br>'; > echo date("Y-m-d", strtotime("sunday", > strtotime("2004-10-18"))); ?> > > Using the code above works fine until the date input is a > Monday then it > outputs the date of the previous Monday. Does anyone know of > another way? I believe my solution to this went something along the lines of strtotime("-6 days monday", ....); It's quite a while since I last used this, so I might not have it quite right, but this should set you on the road. Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: m.ford@leedsmet.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#199866) next »