|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63459 getTimestamp() affected by setTimezone() on DST transition
Submitted: 2012-11-07 21:12 UTC Modified: 2017-03-19 10:53 UTC
Avg. Score:5.0 ± 0.0
Reproduced:4 of 5 (80.0%)
Same Version:1 (25.0%)
Same OS:1 (25.0%)
From: luttkens at gmail dot com Assigned:
Status: Duplicate Package: Date/time related
PHP Version: 7.1 OS: Any
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: luttkens at gmail dot com
New email:
PHP Version: OS:


 [2012-11-07 21:12 UTC] luttkens at gmail dot com
getTimestamp() is supposed to return the time in UNIX-timestamp. To my 
understanding a unix timestamp is always in UTC and not affected by the timezone.

That is; regardless the the timezone, getTimestamp() should return the same value 
for any date. In most cases it does, but not on daylight-saving-time (DST) 

I have create a short script that illustrates the problem.

Test script:
$date1 = new DateTime("@1351382400"); // Sun Oct 28 2012 02:00:00 GMT+2 (DST)
var_dump($date1->getTimestamp()); //prints: 1351382400
$date1->setTimezone(new DateTimeZone("Europe/Stockholm"););
var_dump($date1->getTimestamp()); //prints: 1351386000


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-05-24 12:09 UTC] ryan dot scudellari at bronto dot com
I too have run into this issue with PHP versions 5.3.23 and 5.3.6
 [2014-01-14 00:38 UTC] jeremy at jcarnus dot fr

I have the same problem with timestamp 1382833659 that return 1382837259 on php 5.4.4

Does a fix will be released ?

 [2017-01-16 06:39 UTC]
-PHP Version: 5.4.7RC1 +PHP Version: 7.1
 [2017-01-16 06:39 UTC]
Somethings is different between format('U') and getTimeStamp().

The format('U') returns the correct timestamp whereas getTimestamp returns a wrong one.

 [2017-03-19 10:53 UTC]
-Status: Open +Status: Duplicate
 [2017-03-19 10:53 UTC]
As this is related to the DSTchange back from DST to StandardTime we're now tracking this in
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Jun 15 09:01:23 2021 UTC