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

From: Date: Thu, 17 Nov 2005 12:13:16 +0000
Subject: #35219 [Asn->Bgs]: error in date() - function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-88366@lists.php.net to get a copy of this message
ID: 35219 Updated by: derick@php.net Reported By: mail at harendt dot de -Status: Assigned +Status: Bogus Bug Type: Date/time related Operating System: Linux infong 2.4 #1 SMP Thu Jan PHP Version: 4.4.1 Assigned To: derick New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php http://php.net/date, see the "W" modifier, which returns the ISO week of the year. There is nothing wrong here. Previous Comments: ------------------------------------------------------------------------ [2005-11-14 19:56:25] tony2001@php.net Derick, take a look at it plz. # date -d "2006-01-01 00:00:00" +"%W" 00 ------------------------------------------------------------------------ [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 (#88366) next »