Bug #68286 [Opn]: DateTime::sub crossing DST border starts to add

From: Date: Wed, 22 Oct 2014 16:13:08 +0000
Subject: Bug #68286 [Opn]: DateTime::sub crossing DST border starts to add
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188264@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 User updated by: sam at strictlyphp 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: http://3v4l.org/rYAob Previous Comments: ------------------------------------------------------------------------ [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 (#188264) next »