Quick ? ... how come this doesn't work?

From: Date: Wed, 02 Jul 2003 14:37:27 +0000
Subject: Quick ? ... how come this doesn't work?
Groups: php.general 
Request: Send a blank email to php-general+get-153719@lists.php.net to get a copy of this message
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? - Anthony

« previous php.general (#153719) next »