From:             rikkext1 at drdanger dot com
Operating system: xp / linux
PHP version:      5.1.2
PHP Bug Type:     Date/time related
Bug description:  strtotime off by .04 seconds

Description:
------------
I tripped across this bug calculating the number of days between two
dates. It seems like something goes screwy in April and 0.041666667
seconds get dropped. The code below checks the difference in days between
May 31 and the first 10 days of April. 

Reproduce code:
---------------
for ($iyear=2000;$iyear<= 2006;$iyear++) {
        $s_st=$iyear."-03-31";
        $st=strtotime($s_st);
        for ($i=1;$i<=10;$i++) {
                $addsecs=$st + ($i * 60 * 60 * 24);
                $end = st + $addsecs;
                $s_end=Date("Y-m-d",$end);
                $end = strtotime($s_end);
                $idiff = ($end - $st) / (60 * 60 * 24);
                echo("Start: $s_st End: $s_end Diff: $idiff<br>");
        }
        echo("<hr>");
}


Expected result:
----------------
I would expect to see the number of days between the dates in question 

Actual result:
--------------
Here's the results for just for 2006

Start: 2006-03-31 End: 2006-04-01 Diff: 1
Start: 2006-03-31 End: 2006-04-02 Diff: 2
Start: 2006-03-31 End: 2006-04-03 Diff: 2.9583333333333
Start: 2006-03-31 End: 2006-04-04 Diff: 3.9583333333333
Start: 2006-03-31 End: 2006-04-05 Diff: 4.9583333333333
Start: 2006-03-31 End: 2006-04-06 Diff: 5.9583333333333
Start: 2006-03-31 End: 2006-04-07 Diff: 6.9583333333333
Start: 2006-03-31 End: 2006-04-08 Diff: 7.9583333333333
Start: 2006-03-31 End: 2006-04-09 Diff: 8.9583333333333
Start: 2006-03-31 End: 2006-04-10 Diff: 9.9583333333333


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

Reply via email to