Bug #73071 [NEW]: Datime::createFromFormat timezone bug
| From: | tmcoder at qq dot com | Date: | Tue, 13 Sep 2016 16:03:00 +0000 |
| Subject: | Bug #73071 [NEW]: Datime::createFromFormat timezone bug | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-204006@lists.php.net to get a copy of this message | ||
From: tmcoder at qq dot com
Operating system: CentOS Linux release 7.2.1511
PHP version: 5.6.25
Package: Date/time related
Bug Type: Bug
Bug description:Datime::createFromFormat timezone bug
Description:
------------
---versions---
5.6.25ã7.0.6
---Description---
public static DateTime DateTime::createFromFormat ( string $format ,
string $time [, DateTimeZone $timezone = date_default_timezone_get() ]
)
When format option contain a microsecond string like 'U.u', the tiemzone
option is invalid.
Test script:
---------------
<?php
$timezone = new \DateTimeZone('PRC');
$now = DateTime::createFromFormat('U.u', number_format(microtime(true),
6, '.', ''), $timezone);
print_r($now);
$now->setTimezone($timezone);
print_r($now);
?>
Expected result:
----------------
two results should be equal
Actual result:
--------------
Two results are not equal
DateTime Object
(
[date] => 2016-09-13 15:55:50.946395
[timezone_type] => 1
[timezone] => +00:00
)
DateTime Object
(
[date] => 2016-09-13 23:55:50.946395
[timezone_type] => 3
[timezone] => PRC
)
--
Edit bug report at https://bugs.php.net/bug.php?id=73071&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73071&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73071&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73071&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=73071&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=73071&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=73071&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=73071&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=73071&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=73071&r=support
Expected behavior: https://bugs.php.net/fix.php?id=73071&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=73071&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=73071&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=73071&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73071&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=73071&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=73071&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=73071&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73071&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=73071&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=73071&r=mysqlcfg