From: hcy321+php at yandex dot com
Operating system: OSX
PHP version: 5.4.16
Package: Date/time related
Bug Type: Bug
Bug description:Wrong date diff
Description:
------------
DateTime::diff return wrong result for first day of month.
Tested on PHP Version 5.4.10 \ 5.4.15
Test script:
---------------
<?php
date_default_timezone_set('Europe/Moscow');
$datetime1 = new DateTime('13-03-01');
$datetime2 = new DateTime('13-04-01');
$datetime3 = new DateTime('13-03-02');
$datetime4 = new DateTime('13-04-02');
$interval = $datetime2->diff($datetime1);
echo $interval->format('%m month, %d days'), '<br>'; //1 month, 3 days
$interval = $datetime4->diff($datetime3);
echo $interval->format('%m month, %d days'); //1 month, 0 days
Expected result:
----------------
1 month, 0 days
1 month, 0 days
Actual result:
--------------
1 month, 3 days
1 month, 0 days
--
Edit bug report at https://bugs.php.net/bug.php?id=65003&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=65003&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=65003&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=65003&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=65003&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=65003&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=65003&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=65003&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=65003&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=65003&r=support
Expected behavior: https://bugs.php.net/fix.php?id=65003&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=65003&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=65003&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=65003&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65003&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=65003&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=65003&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=65003&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65003&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=65003&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=65003&r=mysqlcfg