php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60453 ISO Format sets invalid timezone: Z
Submitted: 2011-12-06 23:03 UTC Modified: 2015-01-20 21:21 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: ale at alejandrolapeyre dot com dot ar Assigned: derick (profile)
Status: Not a bug Package: Date/time related
PHP Version: 5.3.8 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ale at alejandrolapeyre dot com dot ar
New email:
PHP Version: OS:

 

 [2011-12-06 23:03 UTC] ale at alejandrolapeyre dot com dot ar
Description:
------------
---
From manual page: http://www.php.net/datetime.construct#refsect1-datetime.construct-description
---

Creating a DateTime from a string in the ISO8601 format "2011-12-06T19:55:34Z" will succeed, but with a DateTimeZone with name "Z". That is incorrect, since "Z" is the way to specify UTC in that ISO format.

Furthermore, if you want to create a DateTimeZone("Z") it will throw.

Best regards, hope this helps to make php better :)

Test script:
---------------
$dt = new DateTime("2011-12-06T19:55:34Z");
$tz = $dt->getTimeZone();
echo $tz->getName();



Expected result:
----------------
"UTC"

Actual result:
--------------
"Z"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-06 23:58 UTC] derick@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: derick
 [2015-01-20 21:21 UTC] derick@php.net
-Status: Assigned +Status: Not a bug
 [2015-01-20 21:21 UTC] derick@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

Timezone "Z" is the same as "UTC", so it's not really wrong. Newer versions of PHP do support (PHP 5.6 at least):

$dt = new DateTimeZone("Z");
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 15 05:01:31 2024 UTC