Edit report at https://bugs.php.net/bug.php?id=61955&edit=1
ID: 61955
Updated by: heiglandreas@php.net
Reported by: php at arjanonline dot net
Summary: Adding DateInterval to DateTime adds 1 additional
hour
-Status: Assigned
+Status: Closed
Type: Bug
Package: Date/time related
Operating System: Linux / Mac
PHP Version: 5.3.12
Assigned To: derick
Block user comment: N
Private report: N
New Comment:
The original issue seems to be fixed in currently supported PHP-Versions. Therefore I'm closing
this issue.
PHP 7.1.2:
php > date_default_timezone_set('Europe/Amsterdam');
php > $d1 = new DateTime('@0');
php > $d2 = clone($d1);
php > $d2->add(new DateInterval('PT5S'));
php > var_dump($d2);
php shell code:1:
class DateTime#5 (3) {
public $date =>
string(26) "1970-01-01 00:00:05.000000"
public $timezone_type =>
int(1)
public $timezone =>
string(6) "+00:00"
}
Previous Comments:
------------------------------------------------------------------------
[2015-03-18 20:11:38] floridia at gmail dot com
Got it. It is not really a bug in my case. That day is the turning point of DST. To work around that
behavior I disabled the DST, changing the timezone to a neutral one (Etc/GMT-3) instead of a
political one (America/Sao Paulo). More detail in Qualcuno's answer here:
http://stackoverflow.com/questions/25478998/disable-daylight-saving-functionality
------------------------------------------------------------------------
[2015-03-18 19:38:57] floridia at gmail dot com
Related with DST Change:
https://bugs.php.net/bug.php?id=51051
------------------------------------------------------------------------
[2015-03-18 19:31:01] floridia at gmail dot com
Similiar issue:
The following code doesn't work with particular date 2015-02-21 23:45:00 when trying to add 15
minutes...
$date1 = new DateTime('2015-02-21 23:45:00');
$interval = new DateInterval('PT15M');
print_r($date1);
$date1->add($interval);
print_r($date1);
Output
DateTime Object
(
[date] => 2015-02-21 23:45:00.000000
[timezone_type] => 3
[timezone] => America/Sao_Paulo
)
DateTime Object
(
[date] => 2015-02-21 23:00:00.000000
[timezone_type] => 3
[timezone] => America/Sao_Paulo
)
Expected Output
DateTime Object
(
[date] => 2015-02-22 00:00:00.000000
[timezone_type] => 3
[timezone] => America/Sao_Paulo
)
------------------------------------------------------------------------
[2013-05-05 12:10:19] jack at jtom dot me
This bug is still up. I'm experiencing it on PHP 5.4.3 and Windows 8 x64 platform.
I had to have 'Europe/Warsaw' set as the default timezone to make the bug occur.
Currently I managed to handle this bug by switching the default timezone to UTC
every time I make date->add/sub/modify , but it's definitely annoying :(
------------------------------------------------------------------------
[2012-11-24 01:15:25] whistl0r+php at googlemail dot com
I think this bug was introduced with http://svn.php.net/viewvc/?view=revision&revision=319767
------------------------------------------------------------------------
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
https://bugs.php.net/bug.php?id=61955
--
Edit this bug report at https://bugs.php.net/bug.php?id=61955&edit=1