|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-03-03 01:51 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 11:00:01 2025 UTC |
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$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'));