Edit report at http://bugs.php.net/bug.php?id=51051&edit=1
ID: 51051 Comment by: danielc at analysisandsolutions dot com Reported by: mehdi dot rande at aliasource dot fr Summary: DateTime modify wrong result with DST change Status: Assigned Type: Bug Package: Date/time related Operating System: Linux PHP Version: 5.3.1 Assigned To: derick Block user comment: N Private report: N New Comment: DateTime::diff() is similarly afflicted with daylight/standard change over issues. Naturally, diff/add/sub all need to be in sync so intervals returned by diff can be passed to add/sub and produce the original datetime. Previous Comments: ------------------------------------------------------------------------ [2010-12-25 02:27:22] dani...@php.net I just attached a test script that covers issues in the spring and fall. ------------------------------------------------------------------------ [2010-12-25 02:26:16] dani...@php.net The following patch has been added/updated: Patch Name: bug51051test.php.txt Revision: 1293240376 URL: http://bugs.php.net/patch-display.php?bug=51051&patch=bug51051test.php.txt&revision=1293240376 ------------------------------------------------------------------------ [2010-08-24 14:34:22] glennpratt+php at gmail dot com Correction for the Expected result above. Expected Result --------------- 2011-03-13T03:00:00-05:00 America/Chicago 2011-03-13T01:58:00-06:00 America/Chicago ------------------------------------------------------------------------ [2010-08-24 00:04:28] glennpratt at gmail dot com Same issue here on PHP 5.3.2 <?php $date = new DateTime('2011-03-13T03:00:00', timezone_open('America/Chicago')); print($date->format('c e')); $date->modify('-2 minutes'); print($date->format('c e')); ?> Actual Result ------------- 2011-03-13T03:00:00-05:00 America/Chicago 2011-03-13T03:58:00-05:00 America/Chicago Expected Result --------------- 2011-03-13T03:00:00-05:00 America/Chicago 2011-03-13T01:58:00-05:00 America/Chicago Comparison: Ruby time library ----------------------------- irb(main):015:0> date = Time.parse('2011-03-13T03:00:00 in CST') => Sun Mar 13 03:00:00 -0500 2011 irb(main):016:0> date - 120 => Sun Mar 13 01:58:00 -0600 2011 ------------------------------------------------------------------------ [2010-02-15 10:56:45] mehdi dot rande at aliasource dot fr Sorry the expected result is in fact the actual result, and the actual result is the expected result. ------------------------------------------------------------------------ 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 http://bugs.php.net/bug.php?id=51051 -- Edit this bug report at http://bugs.php.net/bug.php?id=51051&edit=1