note 61488 added to function.date
| From: | rob at robmacdonald dot com | Date: | Sun, 05 Feb 2006 10:24:02 +0000 |
| Subject: | note 61488 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-103016@lists.php.net to get a copy of this message | ||
This function takes a YEARWEEK value (most commonly returned from mysql) and examines it to get the
start date and end date for the given YEARWEEK. May be of use to someone...
function findWeekPeriod($yearweek){
$aPeriod = array();
$year = substr($yearweek,0,4);
$week = substr($yearweek,4,2);
$startDay = Mon;
$endDay = Sun;
$startdate = strtotime('+' . $week . ' week',mktime(0,0,0,1,1,$year));
$enddate = $startdate;
while(date("D",$startdate) != $startDay){
$startdate = mktime(0,0,0,date("m",$startdate),date("d",$startdate)-1,
date("Y",$startdate));
}
while(date("D",$enddate) != $endDay){
$enddate = mktime(0,0,0,date("m",$enddate),date("d",$enddate)+1,
date("Y",$enddate));
}
return array('start' => date('l d/m/y', $startdate),
'end' => date('l d/m/y', $enddate));
return $aPeriod;
}
----
Server IP: 64.71.164.2
Probable Submitter: 86.10.87.101
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+61488
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61488&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61488&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61488&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61488&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61488&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61488&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61488&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+61488&report=yes
Search -- http://master.php.net/manage/user-notes.php