From:             nic at nicskitt dot co dot uk
Operating system: Windows XP Pro SP1, IIS, ISAPI
PHP version:      4.3.3
PHP Bug Type:     Date/time related
Bug description:  mktime calc fails on specific dates

Description:
------------
When performing the while loop shown in the code mktime function produces
duplicate results on the following specific dates (2004-03-27) and
(2003-03-29) and (2002-03-30). They all seem to be in the month of march.
This starts afer 2001 and I havent yet checked how far it continues.

Because mktime is suppose to handle illegal days and therefore recalcuate
the whole date I cant see why this would happen.



Reproduce code:
---------------
$starting = strtotime("2001-01-01");
$ending = strtotime("2005-01-01");
$newdate = $starting;
$day    = date("d",$newdate);
$month  = date("m",$newdate);
$year   = date("Y",$newdate);

echo("Starting->".date("Y-m-d",$newdate)."<br>");
echo("Ending->".date("Y-m-d",$ending)."<br>");
$x = 0;
while($newdate<$ending){

        $newdate = mktime(0,0,0,$month,($day+$x),$year);
        $fulldate = date("Y-m-d",$newdate);
        echo($fulldate."<br>");
        $x ++;  
}

Expected result:
----------------
Relevant Areas...

2002-03-29
2002-03-30 <- just one as you would expect
2002-04-01
2002-04-02
2002-04-03
...skip output...
2003-03-27
2003-03-28
2003-03-29 <- Just one as you would expect
2003-03-31
2003-04-01

and so on...

Actual result:
--------------
Relevant Areas...

2002-03-28
2002-03-29
2002-03-30 
2002-03-30 <- Duplicate Date
2002-04-01
2002-04-02
...skip output...
2003-03-27
2003-03-28
2003-03-29
2003-03-29 <- Duplicate Date
2003-03-31
2003-04-01

-- 
Edit bug report at http://bugs.php.net/?id=26009&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=26009&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=26009&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=26009&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=26009&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=26009&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=26009&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=26009&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=26009&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=26009&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=26009&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=26009&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26009&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=26009&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=26009&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=26009&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26009&r=float

Reply via email to