Edit report at http://bugs.php.net/bug.php?id=54145&edit=1

 ID:                 54145
 Updated by:         dtajchre...@php.net
 Reported by:        giorgio dot liscio at email dot it
 Summary:            DateTime->add is not affected by DST changes
-Status:             Open
+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:

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$


Previous Comments:
------------------------------------------------------------------------
[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

Reply via email to