Bug #67302 [NEW]: DateTime->setTimezone does not set TZ correctly
| From: | alan at bulbstudios dot com | Date: | Mon, 19 May 2014 12:19:19 +0000 |
| Subject: | Bug #67302 [NEW]: DateTime->setTimezone does not set TZ correctly | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-185859@lists.php.net to get a copy of this message | ||
From: alan at bulbstudios dot com
Operating system: OSX, Debian GNU/Linux
PHP version: 5.5.12
Package: Date/time related
Bug Type: Bug
Bug description:DateTime->setTimezone does not set TZ correctly
Description:
------------
Setting a timezone of either BST, GMT+1, Etc/GMT+1 or CEST on a DateTime
object seems to modify the time of the object and set the timezone
incorrectly.
Works fine on PHP 5.4.28, barring the missing GMT+1.
Test script:
---------------
#!/usr/bin/env php
<?php
echo date_default_timezone_get(), PHP_EOL;
$utc = new DateTimeZone('UTC');
$time = DateTime::createFromFormat('Y-m-d H:i:s', '2014-05-19
11:30:00');
foreach (['BST', 'GMT+1', 'CEST'] as $abbr) {
$time->setTimezone(new DateTimeZone($abbr));
echo "{$abbr}: {$time->format(DATE_RFC822)}", PHP_EOL;
}
Expected result:
----------------
UTC
BST: Mon, 19 May 14 12:30:00 +0100
Etc/GMT+1: Mon, 19 May 14 12:30:00 +0100
GMT+1: Mon, 19 May 14 12:30:00 +0100
CEST: Mon, 19 May 14 14:30:00 +0200
Actual result:
--------------
UTC
BST: Mon, 19 May 14 12:30:00 +0100
Etc/GMT+1: Mon, 19 May 14 11:30:00 -0100
GMT+1: Mon, 19 May 14 13:30:00 +0100
CEST: Mon, 19 May 14 14:30:00 +0100
--
Edit bug report at https://bugs.php.net/bug.php?id=67302&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67302&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67302&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67302&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=67302&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=67302&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=67302&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=67302&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=67302&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=67302&r=support
Expected behavior: https://bugs.php.net/fix.php?id=67302&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=67302&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=67302&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=67302&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67302&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=67302&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=67302&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=67302&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=67302&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=67302&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=67302&r=mysqlcfg