|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-03-26 04:28 UTC] rikkext1 at drdanger dot com
[2006-03-26 05:33 UTC] rikkext1 at drdanger dot com
[2006-03-26 05:35 UTC] rikkext1 at drdanger dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 22 18:00:01 2025 UTC |
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