Edit report at https://bugs.php.net/bug.php?id=51184&edit=1
ID: 51184 Comment by: s...@php.net Reported by: s...@php.net Summary: DateInterval has incorrect days property on windows Status: Wont fix Type: Bug Package: Date/time related Operating System: Windows PHP Version: 5.3.2 Assigned To: pajoye Block user comment: N Private report: N New Comment: Everyone please read the full thread before complaining, it's a bug affecting VC6 builds only. If you are affected just get VC9 builds from http://windows.php.net/download/ - you will also most likely need a VC9 or VC10 build of Apache from http://www.apachelounge.com/download/ VC6 is very old, outdated and not supported anymore, it's easy enough and free to upgrade to newer builds. Previous Comments: ------------------------------------------------------------------------ [2012-03-25 12:47:04] test dot php at yopmail dot com Still have this bug on the 5.3.5 version more than 2 years later. It is not acceptable to have a "won't fix" decision on a major bug like this that is affecting so many people. Thank you in advance, ------------------------------------------------------------------------ [2012-02-06 21:45:11] asdf at asdf dot com Your function can be changed to accept Datetime Objects for Strings this way. Also now calculates datetime difference from dt1 to dt2 rather then the other way around. private function daysdiff($dt1, $dt2, $timeZone = 'America/Chicago') { $tZone = new DateTimeZone($timeZone); if(is_string($dt1)) { $dt1 = new DateTime($dt1, $tZone); } if(is_string($dt2)) { $dt2 = new DateTime($dt2, $tZone); } // use the DateTime datediff function IF we have a non-buggy version // there is a bug in many Windows implementations that diff() always returns 6015 if( $dt1->diff($dt1)->format("%a") != 6015 ) { return $dt1->diff($dt2)->format("%a"); } // else let's use our own method $y1 = $dt1->format('Y'); $y2 = $dt2->format('Y'); $z1 = $dt1->format('z'); $z2 = $dt2->format('z'); $diff = intval($y2 * 365.2425 + $z2) - intval($y1 * 365.2425 + $z1); return $diff; } ------------------------------------------------------------------------ [2012-02-06 21:25:02] asdf at asdf dot com Also have this problem. A full year since last modified. No fixes yet? I agree with the other use who said there should be more documentation on this error. I am sure lots of us spent lots of time before we found this thread trying to figure out why diff() does not output the correct result. Right here would be a great place to put some documentation on the 6015 error: http://us3.php.net/manual/en/datetime.diff.php ------------------------------------------------------------------------ [2012-01-29 05:38:54] alabi10 at yahoo dot com The fix submitted by fbast...@yahoo.com on 2011-10-16 16:13 UTC solved the problem for me on Windows 7 running WAMP on localhost and php 5.3.0 ------------------------------------------------------------------------ [2011-11-12 15:08:05] iskeen at barebrush dot com I am surprised that the number of days between two dates problem is not made clear right up front in the documentation. It took me 3 hours to find this page and I was trying all different things to make it work. I suspected a problem when the three different sets of dates I was using all came out with the same answer, but when I finally used %a and they all came out with 6015, I knew, finally, that there is a problem. The fact of the problem should be made very clear right up front. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=51184 -- Edit this bug report at https://bugs.php.net/bug.php?id=51184&edit=1