Bug #74173 [NEW]: DateTimeImmutable::getTimestamp() triggers DST switch in incorrect time
From: mailtomuller at gmail dot com
Operating system: Debian
PHP version: 5.6.30
Package: Date/time related
Bug Type: Bug
Bug description:DateTimeImmutable::getTimestamp() triggers DST switch in incorrect time
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 bug report at https://bugs.php.net/bug.php?id=74173&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74173&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74173&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74173&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74173&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74173&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74173&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74173&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74173&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74173&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74173&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74173&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74173&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74173&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74173&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74173&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74173&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74173&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74173&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74173&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74173&r=mysqlcfg
Thread (4 messages)
- mailtomuller at gmail dot com