note 66819 deleted from function.date by derick
| From: | derick@php.net | Date: | Sun, 11 Jun 2006 11:48:24 +0000 |
| Subject: | note 66819 deleted from function.date by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-114276@lists.php.net to get a copy of this message | ||
Note Submitter: wmdonkers[at]gmail[dot]com
----
Need all dates in a given week number? a fast solution.
function returns an array of dates in the format "d-m-Y".
suggestions and or comments are more then welcome.
<?php
function getdatesofweek($week)
{
$o = ($week-date("W"))*7;
$c = 8;
$df = "d-m-Y";
while($c>=0){
$td=mktime(12,0,0,date("m"),(date("d")-($c-$o)),date("Y"));
if(date("W",$td)==$week){
$datearray[]=date($df,$td);
}
$c--;
}
$c= 1;
while($c<9){
$td=mktime(12,0,0,date("m"),(date("d")+($c+$o)),date("Y"));
if(date("W",$td)==$week){
$datearray[]=date($df,$td);
}
$c++;
}
return $datearray;
}
?>