Bug #76554 [Nab]: DateTimeImmutable::format() returns invalid result for DST date time
| From: | requinix@php.net | Date: | Sat, 30 Jun 2018 10:59:38 +0000 |
| Subject: | Bug #76554 [Nab]: DateTimeImmutable::format() returns invalid result for DST date time | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-216045@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
Updated by: requinix@php.net
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:
Does your clock show 2am when DST starts? No, because the spring DST transition does not have a 2am.
If you ask PHP for 2am at that moment then it will assume you meant 3am during DST.
Does your clock show 2am when DST ends? Yes, because the fall DST transition does have a 2am. If you
ask PHP for 2am at that moment then PHP assumes you meant 2am standard time. There are actually two
2am times, so if you don't give an explicit UTC offset (eg, CET or CEST) then PHP chooses the
one during standard time.
Previous Comments:
------------------------------------------------------------------------
[2018-06-30 10:42:33] learncomp at mail dot ru
@requinix@php.net, then why it is not changed at the end date -
"2018-10-28T01:00:00+0000"?
------------------------------------------------------------------------
[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