Bug #73071 [Opn->Nab]: Datime::createFromFormat timezone bug
| From: | requinix@php.net | Date: | Tue, 13 Sep 2016 16:12:33 +0000 |
| Subject: | Bug #73071 [Opn->Nab]: Datime::createFromFormat timezone bug | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-204007@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73071&edit=1
ID: 73071
Updated by: requinix@php.net
Reported by: tmcoder at qq dot com
Summary: Datime::createFromFormat timezone bug
-Status: Open
+Status: Not a bug
Type: Bug
Package: Date/time related
Operating System: CentOS Linux release 7.2.1511
PHP Version: 5.6.25
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
http://php.net/manual/en/datetime.createfromformat.php
> Note:
> The timezone parameter and the current timezone are ignored when the time
> parameter either contains a UNIX timestamp (e.g. 946684800) or specifies a
> timezone (e.g. 2010-01-28T15:00:00+02:00).
Previous Comments:
------------------------------------------------------------------------
[2016-09-13 16:02:59] tmcoder at qq dot com
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 this bug report at https://bugs.php.net/bug.php?id=73071&edit=1