note 58443 deleted from function.date by derick
| From: | derick@php.net | Date: | Sun, 11 Jun 2006 11:40:48 +0000 |
| Subject: | note 58443 deleted from function.date by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-114240@lists.php.net to get a copy of this message | ||
Note Submitter: leonardo at kreativ dot ro
----
If you want to find the corresponding starting and ending dates for a given week of a year:
function findWeekPeriod($week, $year)
{
$aPeriod = array();
// if you are a Catholic you should use $x = 0 considering Sunday as the first day of the week.
I'm an Orthodox so I consider it the seventh day of the week
$x = 1;
$aPeriod['start'] = date("Y-m-d H:i:s", mktime(0, 0, 0, 1, 1 + $week*7 + $x -
6, $year));
$aPeriod['end'] = date("Y-m-d H:i:s", mktime(0, 0, 0, 1, 1 + $week*7 + $x,
$year));
return $aPeriod;
}
For week 44 of the year 2005 (as an example), you will get:
Array ( [start] => 2005-10-31 00:00:00 [end] => 2005-11-06 00:00:00 )