Re: Determine week
| From: | Tom Rogers | Date: | Sun, 16 Jun 2002 16:24:01 +0000 |
| Subject: | Re: Determine week | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-102404@lists.php.net to get a copy of this message | ||
Hi
Here is a messy solution, but I think it does what you want using strtotime()
(well worth looking up in the manual :)
<?
$weeks = 30;
$year = date("Y");
$monday1 = strtotime("1 monday",strtotime("1/1/".$year)); //get unix time of first monday of this year
$monday = intval(date("d",$monday1)); //get the day of the month
if($monday != 1):
$week1 = strtotime("-1 week",$monday1); //first week started last year
else:
$week1 = $monday1; //neat this year started on a mondayendif;
$start = strtotime($weeks." monday",$week1); //get unix time of start * the number of weeks
$end = strtotime("next sunday",$start); //get unix time of end
//print them out as dates
echo "Week $weeks start date = ".date("d/m/Y",$start)." end date = ".date("d/m/Y",$end)."<br>";
?>
Tom
At 02:55 AM 16/06/2002 +0300, Rosen wrote:
Hi, how can I determine dates (start & end ) in one week. I.e. 30th week is between 22.07.2002 and 28.07.2002 . -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php