Edit report at https://bugs.php.net/bug.php?id=55253&edit=1
ID: 55253 Updated by: der...@php.net Reported by: danielc at analysisandsolutions dot com Summary: DateTime::add() and sub() result -1 hour on objects with time zone type 2 -Status: Open +Status: Closed Type: Bug Package: Date/time related Operating System: Ubuntu 10.04 PHP Version: 5.4SVN-2011-07-20 (SVN) -Assigned To: +Assigned To: derick Block user comment: N Private report: N New Comment: This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. For Windows: http://windows.php.net/snapshots/ Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2011-11-24 17:13:35] der...@php.net Automatic comment from SVN on behalf of derick Revision: http://svn.php.net/viewvc/?view=revision&revision=319767 Log: - Fixed bug #60236 (TLA timezone dates are not converted properly from timestamp). - Fixed bug #55253 (DateTime::add() and sub() result -1 hour on objects with time zone type 2). And fixed some test cases. ------------------------------------------------------------------------ [2011-11-21 02:19:59] dani...@php.net This is probably related to https://bugs.php.net/bug.php?id=60236 ------------------------------------------------------------------------ [2011-07-20 14:24:08] dani...@php.net Automatic comment from SVN on behalf of danielc Revision: http://svn.php.net/viewvc/?view=revision&revision=313484 Log: Rename and enhance test for bug 55253 now that bugs web is up. ------------------------------------------------------------------------ [2011-07-20 14:18:36] danielc at analysisandsolutions dot com 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 this bug report at https://bugs.php.net/bug.php?id=55253&edit=1