note 28193 rejected from function.strftime by nicos
| From: | nicos@php.net | Date: | Sun, 05 Jan 2003 19:05:57 +0000 |
| Subject: | note 28193 rejected from function.strftime by nicos | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-41694@lists.php.net to get a copy of this message | ||
The previos ISOWeek function seems to work fine, except for one typo:
$week=53 needs to be $week==53.
function ISOWeek($y, $m, $d)
{
$week=strftime("%W", mktime(0, 0, 0, $m, $d, $y));
$dow0101=getdate(mktime(0, 0, 0, 1, 1, $y));
$next0101=getdate(mktime(0, 0, 0, 1, 1, $y+1));
if ($dow0101["wday"]>1 && $dow0101["wday"]<5)
$week++;
if ($next0101["wday"]>1 && $next0101["wday"]<5 &&
$week==53)
$week=1;
if ($week==0)
$week = ISOWeek($y-1,12,31);
return(substr("00" . $week, -2));
}
It helped me out a lot.
Thanx