|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74173 DateTimeImmutable::getTimestamp() triggers DST switch in incorrect time
Submitted: 2017-02-27 10:53 UTC Modified: 2021-04-06 19:54 UTC
Avg. Score:3.8 ± 1.3
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: mailtomuller at gmail dot com Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.6.30 OS: Debian
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: mailtomuller at gmail dot com
New email:
PHP Version: OS:


 [2017-02-27 10:53 UTC] mailtomuller at gmail dot com
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

Online test script:





Test script:

$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";
echo $prg->format('c') . "\n";

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-02-27 10:55 UTC] mailtomuller at gmail dot com
step #4 in the description should be call getTimestamp(), not getTimeZone()
 [2017-02-27 11:27 UTC]
-Assigned To: +Assigned To: derick
 [2017-02-27 14:56 UTC] mailtomuller at gmail dot com
The possibly related bug is , I crosspasted the links.
 [2021-04-06 19:54 UTC]
-Status: Assigned +Status: Closed
 [2021-04-06 19:54 UTC]
The fix for this bug has been committed.
If you are still experiencing this bug, try to check out latest source from and re-test.
Thank you for the report, and for helping us make PHP better.

Fixed for PHP 8.1.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Apr 19 18:01:24 2021 UTC