note 27865 added to function.strftime
| From: | pb at rack1 dot php dot net | Date: | Sat, 21 Dec 2002 14:37:33 +0000 |
| Subject: | note 27865 added to function.strftime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-41183@lists.php.net to get a copy of this message | ||
I am truly sorry - I contributed with a script to overcome the missing %V for Windows-users. It
contained a serious flaw, that prohibited in some cases. Below is a script, that should work in all
cases. I have tested it on most outer cases, e.g. 2005/12/31 and 2006/01/01.
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));
}
Regards
--
http://www.php.net/manual/en/function.strftime.php
http://master.php.net/manage/user-notes.php?action=edit+27865
http://master.php.net/manage/user-notes.php?action=delete+27865
http://master.php.net/manage/user-notes.php?action=reject+27865