From: Operating system: Ubuntu 10.04 PHP version: 5.4SVN-2011-07-20 (SVN) Package: Date/time related Bug Type: Bug Bug description:DateTime::add() and sub() result -1 hour on objects with time zone type 2
Description: ------------ Calling add() or sub() on DateTime objects using a type 2 time zone results in the answer being behind by one hour. Test script has been added to SVN. Test script: --------------- date_default_timezone_set('America/New_York'); $interval = new DateInterval('PT2H1M'); $date3 = new DateTime('2010-10-04 02:18:48'); $date2 = new DateTime('2010-10-04 02:18:48 EDT'); echo 'Zone Type 3: ' . $date3->format('Y-m-d H:i:s T') . "\n"; echo 'Zone Type 2: ' . $date2->format('Y-m-d H:i:s T') . "\n"; echo $interval->format('Add %h hours %i minutes') . "\n"; $date3->add($interval); $date2->add($interval); echo 'Zone Type 3: ' . $date3->format('Y-m-d H:i:s T') . "\n"; echo 'Zone Type 2: ' . $date2->format('Y-m-d H:i:s T') . "\n"; // Try subtracting from expected result. $date3 = new DateTime('2010-10-04 04:19:48'); $date2 = new DateTime('2010-10-04 04:19:48 EDT'); echo $interval->format('Subtract %h hours %i minutes from expected') . "\n"; $date3->sub($interval); $date2->sub($interval); echo 'Zone Type 3: ' . $date3->format('Y-m-d H:i:s T') . "\n"; echo 'Zone Type 2: ' . $date2->format('Y-m-d H:i:s T') . "\n"; Expected result: ---------------- Zone Type 3: 2010-10-04 02:18:48 EDT Zone Type 2: 2010-10-04 02:18:48 EDT Add 2 hours 1 minutes Zone Type 3: 2010-10-04 04:19:48 EDT Zone Type 2: 2010-10-04 04:19:48 EDT Subtract 2 hours 1 minutes from expected Zone Type 3: 2010-10-04 02:18:48 EDT Zone Type 2: 2010-10-04 02:18:48 EDT Actual result: -------------- Zone Type 3: 2010-10-04 02:18:48 EDT Zone Type 2: 2010-10-04 02:18:48 EDT Add 2 hours 1 minutes Zone Type 3: 2010-10-04 04:19:48 EDT Zone Type 2: 2010-10-04 03:19:48 EDT Subtract 2 hours 1 minutes from expected Zone Type 3: 2010-10-04 02:18:48 EDT Zone Type 2: 2010-10-04 01:18:48 EDT -- Edit bug report at https://bugs.php.net/bug.php?id=55253&edit=1 -- Try a snapshot (PHP 5.2): https://bugs.php.net/fix.php?id=55253&r=trysnapshot52 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55253&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55253&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=55253&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55253&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=55253&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=55253&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=55253&r=needscript Try newer version: https://bugs.php.net/fix.php?id=55253&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=55253&r=support Expected behavior: https://bugs.php.net/fix.php?id=55253&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=55253&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=55253&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=55253&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55253&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=55253&r=dst IIS Stability: https://bugs.php.net/fix.php?id=55253&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=55253&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=55253&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=55253&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=55253&r=mysqlcfg Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55253&r=trysnapshot54