Bug #73489 [Asn->Csd]: wrong timestamp when call setTimeZone multi times with UTC offset
| From: | derick@php.net | Date: | Sun, 12 Feb 2017 20:20:26 +0000 |
| Subject: | Bug #73489 [Asn->Csd]: wrong timestamp when call setTimeZone multi times with UTC offset | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-207297@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73489&edit=1
ID: 73489
Updated by: derick@php.net
Reported by: fernando dot dias at flechaweb dot com dot br
Summary: wrong timestamp when call setTimeZone multi times
with UTC offset
-Status: Assigned
+Status: Closed
Type: Bug
Package: Date/time related
Operating System: Ubuntu
PHP Version: 7.0.13
Assigned To: jhdxr
Block user comment: N
Private report: N
New Comment:
The fix for this bug has been committed.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2016-11-10 18:48:50] fernando dot dias at flechaweb dot com dot br
Description:
------------
I know that UTC offset is not the better approach to solve timezone issues, even more than region
has DST. But in some situations the offset is the only way that you have to manipulate Timezone.
In this situation with you interact with a DateTime object setting TimeZone more the once, it can
cause some strange situations, some cases, event timestamp from DateTime appears to be changed.
Test script:
---------------
I got some situations with DateTime and DateTimeZone appears not showing data in the right way.
// example 1 - Timestamp is changing
$datetime = new DateTime('2016-11-09 20:00:00', new DateTimeZone('UTC'));
var_dump($datetime->getTimestamp());
$datetime->setTimeZone(new DateTimeZone('-03:00'));
$datetime->setTimeZone(new DateTimeZone('-03:00'));
var_dump($datetime->getTimestamp());
// example 2 - Timestamp keeps if you use getTimestamp() before second setTimeZone() calls
$datetime = new DateTime('2016-11-09 20:00:00', new DateTimeZone('UTC'));
var_dump($datetime->getTimestamp());
$datetime->setTimeZone(new DateTimeZone('-03:00'));
$datetime->getTimestamp();
$datetime->setTimeZone(new DateTimeZone('-03:00'));
var_dump($datetime->getTimestamp());
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73489&edit=1