#35219 [Opn->Asn]: error in date() - function

From: Date: Mon, 14 Nov 2005 18:56:26 +0000
Subject: #35219 [Opn->Asn]: error in date() - function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-88163@lists.php.net to get a copy of this message
ID: 35219 Updated by: tony2001@php.net Reported By: mail at harendt dot de -Status: Open +Status: Assigned Bug Type: Date/time related Operating System: Linux infong 2.4 #1 SMP Thu Jan PHP Version: 4.4.1 -Assigned To: +Assigned To: derick New Comment: Derick, take a look at it plz. # date -d "2006-01-01 00:00:00" +"%W" 00 Previous Comments: ------------------------------------------------------------------------ [2005-11-14 19:01:58] mail at harendt dot de Description: ------------ The function "date" called with the parameter "W" to give the number of the week is wrong when thr year turns. For example the function give for sunday, 01.01.2006 the week number 52. Reproduce code: --------------- <?php $Dez05 = mktime(0, 0, 0, 12, 28, 2005); $aHour = 60*60; $aDay = $aHour * 24; for ($d = 0; $d <= 5; $d++) { $Day00 = $Dez05 + $d * $aDay; for ($ih = 0; $ih < 3; $ih++) { $h=8*$ih; $TS = $Day00 + $h * $aHour; $DAY = date("D",$TS); $nrDAY = date("d",$TS); $HR = date("H",$TS); $MIN = date("i",$TS); $MNTH = date("m",$TS); $YEAR = date("y",$TS); $WEEK = date("W",$TS); $WEEK = sprintf ("%02d", $WEEK); $sd = sprintf ("%02d", $d); $sh = sprintf ("%02d", $h); echo "$TS ($sd, $sh) --> week = <b>$WEEK</b>, $DAY, $nrDAY.$MNTH.$YEAR, $HR.$MIN </br>"; } } ?> Expected result: ---------------- 1135724400 (00, 00) --> week = 52, Wed, 28.12.05, 00.00 1135753200 (00, 08) --> week = 52, Wed, 28.12.05, 08.00 1135782000 (00, 16) --> week = 52, Wed, 28.12.05, 16.00 1135810800 (01, 00) --> week = 52, Thu, 29.12.05, 00.00 1135839600 (01, 08) --> week = 52, Thu, 29.12.05, 08.00 1135868400 (01, 16) --> week = 52, Thu, 29.12.05, 16.00 1135897200 (02, 00) --> week = 52, Fri, 30.12.05, 00.00 1135926000 (02, 08) --> week = 52, Fri, 30.12.05, 08.00 1135954800 (02, 16) --> week = 52, Fri, 30.12.05, 16.00 1135983600 (03, 00) --> week = 52, Sat, 31.12.05, 00.00 1136012400 (03, 08) --> week = 52, Sat, 31.12.05, 08.00 1136041200 (03, 16) --> week = 52, Sat, 31.12.05, 16.00 1136070000 (04, 00) --> week = 52, Sun, 01.01.06, 00.00 !! 1136098800 (04, 08) --> week = 52, Sun, 01.01.06, 08.00 !! 1136127600 (04, 16) --> week = 52, Sun, 01.01.06, 16.00 !! 1136156400 (05, 00) --> week = 01, Mon, 02.01.06, 00.00 1136185200 (05, 08) --> week = 01, Mon, 02.01.06, 08.00 1136214000 (05, 16) --> week = 01, Mon, 02.01.06, 16.00 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=35219&edit=1

« previous php.bugs (#88163) next »