Bug #63459 [Opn->Dup]: getTimestamp() affected by setTimezone() on DST transition

From: Date: Sun, 19 Mar 2017 10:53:12 +0000
Subject: Bug #63459 [Opn->Dup]: getTimestamp() affected by setTimezone() on DST transition
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207942@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63459&edit=1 ID: 63459 Updated by: heiglandreas@php.net Reported by: luttkens at gmail dot com Summary: getTimestamp() affected by setTimezone() on DST transition -Status: Open +Status: Duplicate Type: Bug Package: Date/time related Operating System: Any PHP Version: 7.1 Block user comment: N Private report: N New Comment: As this is related to the DSTchange back from DST to StandardTime we're now tracking this in https://bugs.php.net/bug.php?id=74274 Previous Comments: ------------------------------------------------------------------------ [2017-01-16 06:39:50] heiglandreas@php.net Somethings is different between format('U') and getTimeStamp(). The format('U') returns the correct timestamp whereas getTimestamp returns a wrong one. See https://3v4l.org/cVRBI ------------------------------------------------------------------------ [2015-04-20 03:14:51] pasindu@php.net http://3v4l.org/pts6t ------------------------------------------------------------------------ [2014-01-14 00:38:56] jeremy at jcarnus dot fr Hello, I have the same problem with timestamp 1382833659 that return 1382837259 on php 5.4.4 Does a fix will be released ? Thanks ------------------------------------------------------------------------ [2013-05-24 12:09:54] ryan dot scudellari at bronto dot com I too have run into this issue with PHP versions 5.3.23 and 5.3.6 ------------------------------------------------------------------------ [2012-11-07 21:12:28] luttkens at gmail dot com Description: ------------ 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) transitions. 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63459&edit=1

« previous php.bugs (#207942) next »