|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2016-11-11 01:15 UTC] requinix@php.net
-Package: PHP Language Specification
+Package: Date/time related
[2016-11-16 12:02 UTC] jhdxr@php.net
-Summary: DateTimeZone Type 1 UTC offset
+Summary: wrong timestamp when call setTimeZone multi
times with UTC offset
-Status: Open
+Status: Assigned
-Assigned To:
+Assigned To: jhdxr
[2017-02-12 20:20 UTC] derick@php.net
-Status: Assigned
+Status: Closed
[2017-02-12 20:20 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 02:00:01 2025 UTC |
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());