Bug #74173 [Asn->Csd]: DateTimeImmutable::getTimestamp() triggers DST switch in incorrect time
| From: | derick@php.net | Date: | Tue, 06 Apr 2021 19:54:12 +0000 |
| Subject: | Bug #74173 [Asn->Csd]: DateTimeImmutable::getTimestamp() triggers DST switch in incorrect time | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-233257@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74173&edit=1
ID: 74173
Updated by: derick@php.net
Reported by: mailtomuller at gmail dot com
Summary: DateTimeImmutable::getTimestamp() triggers DST
switch in incorrect time
-Status: Assigned
+Status: Closed
Type: Bug
Package: Date/time related
Operating System: Debian
PHP Version: 5.6.30
Assigned To: derick
Block user comment: N
Private report: N
New Comment:
The fix for this bug has been committed.
If you are still experiencing this bug, try to check out latest source from https://github.com/php/php-src and re-test.
Thank you for the report, and for helping us make PHP better.
Fixed for PHP 8.1.
Previous Comments:
------------------------------------------------------------------------
[2017-02-27 14:56:11] mailtomuller at gmail dot com
The possibly related bug is https://bugs.php.net/bug.php?id=67634 , I
crosspasted the links.
------------------------------------------------------------------------
[2017-02-27 10:55:38] mailtomuller at gmail dot com
step #4 in the description should be call getTimestamp(), not getTimeZone()
------------------------------------------------------------------------
[2017-02-27 10:53:52] mailtomuller at gmail dot com
Description:
------------
All PHP versions affected: 5.6.0 - 5.6.30, 7.0.0 - 7.1.2
- create DateTimeImmutable in UTC, hour before the actual DST switch
- change its timezone to Europe/Prague that observes DST
- absolute date/time stays the same, UTC offset is correctly changed
- call getTimeZone() on the instance
- the offset moves as if it went past the DST switch
Might be related to https://bugs.php.net/bug.php?id=65502
Online test script: https://3v4l.org/pQaKo
Expected:
2016-10-30T02:00:00+02:00
2016-10-30T02:00:00+02:00
Actual:
2016-10-30T02:00:00+02:00
2016-10-30T02:00:00+01:00
Test script:
---------------
<?php
$utc = new \DateTimeImmutable('2016-10-30T00:00:00+00:0');
// reproduces too:
// $utc = new \DateTimeImmutable('2016-10-30T00:00:00', new
\DateTimeZone('UTC'));
// $utc = new \DateTimeImmutable('2016-10-30T00:00:00+00:0');
$prg = $utc->setTimeZone(new \DateTimeZone('Europe/Prague'));
echo $prg->format('c') . "\n";
$prg->getTimestamp();
echo $prg->format('c') . "\n";
Expected result:
----------------
2016-10-30T02:00:00+02:00
2016-10-30T02:00:00+02:00
Actual result:
--------------
2016-10-30T02:00:00+02:00
2016-10-30T02:00:00+01:00
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74173&edit=1