Bug #73489 [Opn->Asn]: wrong timestamp when call setTimeZone multi times with UTC offset
| From: | jhdxr@php.net | Date: | Wed, 16 Nov 2016 12:03:00 +0000 |
| Subject: | Bug #73489 [Opn->Asn]: wrong timestamp when call setTimeZone multi times with UTC offset | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-205405@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: jhdxr@php.net
Reported by: fernando dot dias at flechaweb dot com dot br
-Summary: DateTimeZone Type 1 UTC offset
+Summary: wrong timestamp when call setTimeZone multi times
with UTC offset
-Status: Open
+Status: Assigned
Type: Bug
Package: Date/time related
Operating System: Ubuntu
PHP Version: 7.0.13
-Assigned To:
+Assigned To: jhdxr
Block user comment: N
Private report: N
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