note 27865 deleted from function.strftime by derick

From: Date: Sat, 04 Nov 2006 10:44:40 +0000
Subject: note 27865 deleted from function.strftime by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-119386@lists.php.net to get a copy of this message
Note Submitter: pb at pedal dot dk ---- 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

« previous php.notes (#119386) next »