note 27821 added to function.strftime
| From: | pb at rack1 dot php dot net | Date: | Thu, 19 Dec 2002 20:55:24 +0000 |
| Subject: | note 27821 added to function.strftime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-41134@lists.php.net to get a copy of this message | ||
I have found out a way to make a function that should work to find out which week number a specific
date bellongs to:
function ISOWeek($y, $m, $d)
{
$week=strftime("%W", mktime(0, 0, 0, $m, $d, $y));
$dow0101=getdate(mktime(0, 0, 0, 1, 1, $y));
if ($dow0101["wday"]>1 && $dow0101["wday"]<5)
$week++;
elseif ($week==0)
$week=ISOWeek($y-1,12,31);
if ($week==53 && $m==12)
$week=ISOWeek($y+1,1,1);
return(substr("00" . $week, -2));
}
(This is just an adjustment of a previous script)
--
http://www.php.net/manual/en/function.strftime.php
http://master.php.net/manage/user-notes.php?action=edit+27821
http://master.php.net/manage/user-notes.php?action=delete+27821
http://master.php.net/manage/user-notes.php?action=reject+27821