Edit report at http://bugs.php.net/bug.php?id=54145&edit=1
ID: 54145 Updated by: der...@php.net Reported by: giorgio dot liscio at email dot it Summary: DateTime->add is not affected by DST changes Status: Bogus Type: Bug Package: Date/time related Operating System: all? PHP Version: 5.3.5 Block user comment: N Private report: N New Comment: The time is not supposed to update. One month is a month, not 31 (or 30) * 86400 seconds. You will also see that "P1D" adds one to the day, and does not bother with the hours. A day at the DST change over is simply 25 hours (or 23 hours). Previous Comments: ------------------------------------------------------------------------ [2011-03-03 15:23:59] giorgio dot liscio at email dot it here is it with your testcase, using time too in the constructor, the time itself is not update date_default_timezone_set('America/Chicago'); $d = new \DateTime('03-march-2011 10:10:10'); var_dump($d->format('c')); $d->add(new \DateInterval('P1M')); var_dump($d->format('c')); date_default_timezone_set('Europe/Rome'); $d = new \DateTime('03-march-2011 10:10:10'); var_dump($d->format('c')); $d->add(new \DateInterval('P1M')); var_dump($d->format('c')); ------------------------------------------------------------------------ [2011-03-03 15:05:18] giorgio dot liscio at email dot it so what? in your code this is working, right? in this case i will investigate on the mine ------------------------------------------------------------------------ [2011-03-03 05:28:52] dtajchre...@php.net david@copenhagen:~/test$ php -v PHP 5.3.6-dev (cli) (built: Feb 26 2011 23:29:38) (DEBUG) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies david@copenhagen:~/test$ cat t.php <?php date_default_timezone_set('America/Chicago'); $d = new DateTime('03-march-2011'); var_dump($d->format('c')); $d->add(new DateInterval('P1M')); var_dump($d->format('c')); date_default_timezone_set('Europe/Rome'); $d = new DateTime('03-march-2011'); var_dump($d->format('c')); $d->add(new DateInterval('P1M')); var_dump($d->format('c')); david@copenhagen:~/test$ php t.php string(25) "2011-03-03T00:00:00-06:00" string(25) "2011-04-03T00:00:00-05:00" string(25) "2011-03-03T00:00:00+01:00" string(25) "2011-04-03T00:00:00+02:00" david@copenhagen:~/test$ ------------------------------------------------------------------------ [2011-03-03 02:03:27] giorgio dot liscio at email dot it proposed solution: ->add and ->sub methods should internally convert to UTC before add or sub the interval, then should re-set the original timezone ------------------------------------------------------------------------ [2011-03-03 01:51:35] giorgio dot liscio at email dot it Description: ------------ hi when dateinterval walks across a dst change $a = DateTime::createFromFormat ( "d/m/Y H:i:s e", "03/03/2011 01:38:25 europe/rome" ); $a = $a->add(new DateInterval("P1M")); // now we have DST in italy should add +1 hour too, I think, but it doesn't thank you ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=54145&edit=1