Bug #63953 [NEW]: DateTime::diff produces a wrong DateInterval on DST change

From: Date: Wed, 09 Jan 2013 16:45:28 +0000
Subject: Bug #63953 [NEW]: DateTime::diff produces a wrong DateInterval on DST change
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-175914@lists.php.net to get a copy of this message
From: gianluca dot pinna at allbus dot com Operating system: Linux 64 PHP version: 5.3.20 Package: Date/time related Bug Type: Bug Bug description:DateTime::diff produces a wrong DateInterval on DST change Description: ------------ I have two dates, the second date is after a DST change. I tried to get a diff between the two dates. Computing the difference between the timestamps I get the correct result (33 hours). Using DateTime->diff() I get 34 hours. Is this expected? Test script: --------------- <?php $originDate = new DateTime('2013-03-30 00:00:00', new DateTimeZone('Europe/Rome')); $destinationDate = new DateTime('2013-03-31 10:00:00', new DateTimeZone('Europe/Rome')); $diff = $destinationDate->getTimestamp() - $originDate->getTimestamp(); $dateinterval = $originDate->diff($destinationDate); var_dump($diff/3600); var_dump($dateinterval->d*24 + $dateinterval->h); // int(33) // int(34) Expected result: ---------------- I would expect to always get 33 hours. -- Edit bug report at https://bugs.php.net/bug.php?id=63953&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63953&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63953&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63953&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=63953&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=63953&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=63953&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=63953&r=needscript Try newer version: https://bugs.php.net/fix.php?id=63953&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=63953&r=support Expected behavior: https://bugs.php.net/fix.php?id=63953&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=63953&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=63953&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=63953&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63953&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=63953&r=dst IIS Stability: https://bugs.php.net/fix.php?id=63953&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=63953&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=63953&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=63953&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=63953&r=mysqlcfg

« previous php.bugs (#175914) next »