On Wednesday 02 July 2003 22:37, Anthony wrote:
Please use a descriptive subject!
> I'm trying to get the 1st and last day of the current week. I ty to do
> this:
> $startofweek = date("Y-m-d",mktime (0,0,0,date("m")
> ,date("d")-date("w"),date("Y")));
> $endofweek = date("Y-m-d",mktime (0,0,0,date("m")
> ,date("d",strtotime($startofweek))+6,date("Y")));
> echo $startofweek." --- ".$endofweek;
>
> $startofweek is correct, but if you run it for a week that has it's
> beginning date in an other month (like this week), the $endofweek is in
> the wrong month. What gives? If I change -date("w") to -1 or anything
> else that stays within the current month, it works. What do you think? Is
> there a better way to do this?
Something simple like this ought to work:
echo strftime('%Y-%m-%d', strtotime ("Sunday")), "\n";
echo strftime('%Y-%m-%d', strtotime ("last Monday")), "\n";
For the first day of the week you may need to check whether it is already a
Monday (or Sunday depending on your conventions).
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Afternoon very favorable for romance. Try a single person for a change.
*/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php