From:             mail at harendt dot de
Operating system: Linux infong 2.4 #1 SMP Thu Jan 
PHP version:      4.4.1
PHP Bug Type:     Date/time related
Bug description:  error in date() - function

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 bug report at http://bugs.php.net/?id=35219&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=35219&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=35219&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=35219&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=35219&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=35219&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=35219&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=35219&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=35219&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=35219&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=35219&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=35219&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=35219&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=35219&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=35219&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=35219&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=35219&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=35219&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=35219&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=35219&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=35219&r=mysqlcfg

Reply via email to