Bug #63311 [Opn->Dup]: DateTime::add() adds wrong interval when switching from summer to winter time
| From: | heiglandreas@php.net | Date: | Sun, 19 Mar 2017 10:47:42 +0000 |
| Subject: | Bug #63311 [Opn->Dup]: DateTime::add() adds wrong interval when switching from summer to winter time | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-207941@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63311&edit=1
ID: 63311
Updated by: heiglandreas@php.net
Reported by: thomas dot mayer at 2bis10 dot de
Summary: DateTime::add() adds wrong interval when switching
from summer to winter time
-Status: Open
+Status: Duplicate
Type: Bug
Package: Date/time related
Operating System: Windows 7, debian 6
PHP Version: 7.1
Block user comment: N
Private report: N
New Comment:
We're now tracking this in https://bugs.php.net/bug.php?id=74274
Previous Comments:
------------------------------------------------------------------------
[2016-02-18 08:44:32] jan dot machala at email dot cz
Problem still persists in newest php versions. There is online php shell test, which detects which
php versions are affected (https://3v4l.org/femQK).
------------------------------------------------------------------------
[2014-11-11 08:21:26] YAfrourner5561 at superrito dot com
Bug still persists
------------------------------------------------------------------------
[2014-03-31 11:37:28] nj dot johansson at gmail dot com
Seems like there are many similar reported bugs that might be related to the same underlying issue:
https://bugs.php.net/bug.php?id=51051
https://bugs.php.net/bug.php?id=60960
https://bugs.php.net/bug.php?id=61530
https://bugs.php.net/bug.php?id=62331
https://bugs.php.net/bug.php?id=62327
------------------------------------------------------------------------
[2014-03-31 11:27:18] nj dot johansson at gmail dot com
Experiencing the same thing on PHP 5.4.26 (RHEL 5.6) when subtracting an hour at the time across DST
boundary.
Test script:
---------------
// Init DateTime after DST change
$dt = new DateTime('2014-03-30 05:03:00', new DateTimeZone('Europe/Berlin'));
$di = new DateInterval('PT1H');
// Subtract one hour each time and notice how time is stuck
echo $dt->format('Y-m-d H:i:s') . "\n";
$dt->sub($di);
echo $dt->format('Y-m-d H:i:s') . "\n";
$dt->sub($di);
echo $dt->format('Y-m-d H:i:s') . "\n";
$dt->sub($di);
echo $dt->format('Y-m-d H:i:s') . "\n";
$dt->sub($di);
echo $dt->format('Y-m-d H:i:s') . "\n";
Result:
-----------------
2014-03-30 05:03:00
2014-03-30 04:03:00
2014-03-30 03:03:00
2014-03-30 03:03:00
2014-03-30 03:03:00
2014-03-30 03:03:00
------------------------------------------------------------------------
[2013-07-03 15:01:06] mas at crosscan dot com
For me it seems not to be directly connected with switching from or to DST.
I tried the following
Test script:
----------------
date_default_timezone_set( 'Europe/Berlin' );
$date = new \DateTime( '@0' );
echo $date->format('c')."\n";
$interval = new \DateInterval( 'PT1H' );
$date->add($interval);
echo $date->format('c')."\n";
$date->add($interval);
echo $date->format('c')."\n";
Expected result:
------------------
1970-01-01T00:00:00+00:00
1970-01-01T01:00:00+00:00
1970-01-01T02:00:00+00:00
Actual result:
----------------
1970-01-01T00:00:00+00:00
1970-01-01T02:00:00+00:00
1970-01-01T04:00:00+00:00
------------------------------------------------------------------------
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=63311
--
Edit this bug report at https://bugs.php.net/bug.php?id=63311&edit=1