Bug #74173 [Opn]: DateTimeImmutable::getTimestamp() triggers DST switch in incorrect time
Edit report at https://bugs.php.net/bug.php?id=74173&edit=1
ID: 74173
User updated by: mailtomuller at gmail dot com
Reported by: mailtomuller at gmail dot com
Summary: DateTimeImmutable::getTimestamp() triggers DST
switch in incorrect time
Status: Open
Type: Bug
Package: Date/time related
Operating System: Debian
PHP Version: 5.6.30
Block user comment: N
Private report: N
New Comment:
step #4 in the description should be call getTimestamp(), not getTimeZone()
Previous Comments:
------------------------------------------------------------------------
[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
Thread (4 messages)