ID:               36861
 User updated by:  rikkext1 at drdanger dot com
 Reported By:      rikkext1 at drdanger dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Date/time related
 Operating System: xp / linux
 PHP Version:      5.1.2
 New Comment:

See last comment. I'm an idiot. Sorry.


Previous Comments:
------------------------------------------------------------------------

[2006-03-26 05:33:13] rikkext1 at drdanger dot com

Just noticed, the seconds get dropped at the beginning of DST.

------------------------------------------------------------------------

[2006-03-26 04:28:25] rikkext1 at drdanger dot com

(Sorry, meant to say "difference between MARCH 31 and the first 10 days
of April")

------------------------------------------------------------------------

[2006-03-26 04:23:33] rikkext1 at drdanger dot com

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 this bug report at http://bugs.php.net/?id=36861&edit=1

Reply via email to