Bug #68286 [Ver->Dup]: DateTime::sub crossing DST border starts to add

From: Date: Sun, 19 Mar 2017 11:37:40 +0000
Subject: Bug #68286 [Ver->Dup]: DateTime::sub crossing DST border starts to add
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207950@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68286&edit=1 ID: 68286 Updated by: heiglandreas@php.net Reported by: sam at strictlyphp dot com Summary: DateTime::sub crossing DST border starts to add -Status: Verified +Status: Duplicate Type: Bug Package: Date/time related Operating System: Irrelevant PHP Version: Irrelevant 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-09-29 17:53:57] cmb@php.net Indeed, there appears to be a regression in PHP 5.4.24, which still isn't resolved, see <https://3v4l.org/rYAob>. ------------------------------------------------------------------------ [2016-03-30 08:15:23] marc dot fricou at iadvize dot com 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 ------------------------------------------------------------------------ [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

« previous php.bugs (#207950) next »