Bug #76554 [NEW]: DateTimeImmutable::format() returns invalid result for DST date time
| From: | learncomp at mail dot ru | Date: | Sat, 30 Jun 2018 09:20:47 +0000 |
| Subject: | Bug #76554 [NEW]: DateTimeImmutable::format() returns invalid result for DST date time | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-216041@lists.php.net to get a copy of this message | ||
From: learncomp at mail dot ru
Operating system: Linux, 4.16.13-2-ARCH
PHP version: 7.3.0alpha2
Package: Date/time related
Bug Type: Bug
Bug description:DateTimeImmutable::format() returns invalid result for DST date time
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 bug report at https://bugs.php.net/bug.php?id=76554&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76554&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76554&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76554&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76554&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76554&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76554&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76554&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76554&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76554&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76554&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76554&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76554&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76554&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76554&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76554&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76554&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76554&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76554&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76554&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76554&r=mysqlcfg