Bug #68286 [Com]: DateTime::sub crossing DST border starts to add
Edit report at https://bugs.php.net/bug.php?id=68286&edit=1
ID: 68286
Comment by: marc dot fricou at iadvize dot com
Reported by: sam at strictlyphp dot com
Summary: DateTime::sub crossing DST border starts to add
Status: Open
Type: Bug
Package: *General Issues
Operating System: Irrelevant
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
I think i have the same problem. I can't sub() an hour to a DateTime that is set to the DST
hour :
https://3v4l.org/RJ2Df
Previous Comments:
------------------------------------------------------------------------
[2014-10-22 16:13:08] sam at strictlyphp dot com
http://3v4l.org/rYAob
------------------------------------------------------------------------
[2014-10-22 15:41:16] sam at strictlyphp dot com
Description:
------------
Starting with a date in standard time and subtracting over the DST "border", suddenly adds
time.
Line 5 in the actual result below seems to be wrong.
Happens in all PHP versions from 5.4.24 & 5.5.8 onwards.
Test script:
---------------
$tz = new DateTimeZone('Europe/Brussels');
$date = new DateTime('2014-10-26T03:00:00', $tz);
$interval = new DateInterval('PT30M');
for ($i = 0; $i < 5; $i++) {
echo $date->sub($interval)->format('c e T') . PHP_EOL;
}
Expected result:
----------------
2014-10-26T02:30:00+01:00 Europe/Brussels CET
2014-10-26T02:00:00+01:00 Europe/Brussels CET
2014-10-26T02:30:00+02:00 Europe/Brussels CEST
2014-10-26T02:00:00+02:00 Europe/Brussels CEST
2014-10-26T01:30:00+02:00 Europe/Brussels CEST
Actual result:
--------------
2014-10-26T02:30:00+01:00 Europe/Brussels CET
2014-10-26T02:00:00+01:00 Europe/Brussels CET
2014-10-26T02:30:00+02:00 Europe/Brussels CEST
2014-10-26T02:00:00+02:00 Europe/Brussels CEST
2014-10-26T02:30:00+02:00 Europe/Brussels CEST
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68286&edit=1
Thread (5 messages)