[PHP-BUG] Bug #73489 [NEW]: DateTimeZone Type 1 UTC offset
[email protected] ("fernando dot dias at flechaweb dot com dot br") Thu, 10 Nov 2016 18:48:53 GMT
| Newsgroups | php.standards |
|---|---|
| Message-ID | <[email protected]> |
From: fernando dot dias at flechaweb dot com dot br
Operating system: Ubuntu
PHP version: 7.0.13
Package: PHP Language Specification
Bug Type: Bug
Bug description:DateTimeZone Type 1 UTC offset
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 bug report at https://bugs.php.net/bug.php?id=73489&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73489&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73489&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73489&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=73489&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=73489&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=73489&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=73489&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=73489&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=73489&r=support
Expected behavior: https://bugs.php.net/fix.php?id=73489&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=73489&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=73489&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=73489&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73489&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=73489&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=73489&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=73489&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73489&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=73489&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=73489&r=mysqlcfg