Bug #76554 [Com]: DateTimeImmutable::format() returns invalid result for DST date time

From: Date: Sat, 30 Jun 2018 10:42:34 +0000
Subject: Bug #76554 [Com]: DateTimeImmutable::format() returns invalid result for DST date time
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216044@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76554&edit=1 ID: 76554 Comment by: learncomp at mail dot ru Reported by: learncomp at mail dot ru Summary: DateTimeImmutable::format() returns invalid result for DST date time Status: Not a bug Type: Bug Package: Date/time related Operating System: Linux, 4.16.13-2-ARCH PHP Version: 7.3.0alpha2 Block user comment: N Private report: N New Comment: @requinix@php.net, then why it is not changed at the end date - "2018-10-28T01:00:00+0000"? Previous Comments: ------------------------------------------------------------------------ [2018-06-30 09:30:10] requinix@php.net Can you remind me exactly what happens at the moment spring DST begins? ------------------------------------------------------------------------ [2018-06-30 09:20:44] learncomp at mail dot ru Description: ------------ Europe/Oslo has DST and it occurs at (got with (new DateTimeZone("Europe/Oslo"))->getTransitions()): ``` [ "ts" => 1521939600, "time" => "2018-03-25T01:00:00+0000", "offset" => 7200, "isdst" => true, "abbr" => "CEST", ], [ "ts" => 1540688400, "time" => "2018-10-28T01:00:00+0000", "offset" => 3600, "isdst" => false, "abbr" => "CET", ], ``` The following test script increments the input date time to 1 hour which should not occur?. I'm not sure either this is a bug or not as I don't have enough information to decide but probably it can be the bug. Test script: --------------- <?php // For the start date time + 1 hour it prints 2018-03-25 03:00:00, which is incorrect? echo (new \DateTimeImmutable('2018-03-25 02:00:00', new \DateTimeZone('Europe/Oslo')))->format('Y-m-d H:i:s'); // However for the end date time it does not change the value, tried for the dates: "2018-10-27 23:00:00", "2018-10-28 00:00:00", "2018-10-28 01:00:00", "2018-10-28 02:00:00", "2018-10-28 03:00:00", "2018-10-28 04:00:00", "2018-10-28 05:00:00", "2018-10-28 06:00:00" like so: // echo (new \DateTimeImmutable('2018-10-28 03:00:00', new \DateTimeZone('Europe/Oslo')))->format('Y-m-d H:i:s'); // It always returns the same value, which I think is correct. Expected result: ---------------- 2018-03-25 02:00:00 Actual result: -------------- 2018-03-25 03:00:00 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76554&edit=1

« previous php.bugs (#216044) next »