php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #74324 DateTimeZone supported timezone names
Submitted: 2017-03-28 08:12 UTC Modified: 2017-03-28 10:28 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: graeme dot chapman at infinitycloud dot com Assigned:
Status: Closed Package: Date/time related
PHP Version: 5.6.30 OS: Ubuntu
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: graeme dot chapman at infinitycloud dot com
New email:
PHP Version: OS:

 

 [2017-03-28 08:12 UTC] graeme dot chapman at infinitycloud dot com
Description:
------------
---
From manual page: http://www.php.net/datetimezone.construct
---

The documentation states that the DateTimeZone constructor accepts 'One of the supported timezone names(http://php.net/manual/en/timezones.php).' 

However, it also appears to accept offset values. Unsure if this is expected but undocumented behaviour, or a bug. In PHP 5.5.9 this throws an exception. 

Test script:
---------------
var_dump(new DateTimeZone('+0200'));

Expected result:
----------------
Uncaught exception 'Exception' with message 'DateTimeZone::__construct(): Unknown or bad timezone (+0200)'

Actual result:
--------------
object(DateTimeZone)#1 (2) {
  ["timezone_type"]=>
  int(1)
  ["timezone"]=>
  string(6) "+02:00"
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-28 08:39 UTC] requinix@php.net
-Status: Open +Status: Verified
 [2017-03-28 08:39 UTC] requinix@php.net
timelib (which PHP uses) explicitly supports offset notation in addition to the usual named timezones; see the "tzcorrection" format in
  http://php.net/manual/en/datetime.formats.time.php

Ref:
  https://github.com/php/php-src/blob/PHP-5.6.30/ext/date/lib/parse_date.re#L746
  https://github.com/php/php-src/blob/PHP-5.6.30/ext/date/lib/timelib.c#L311
 [2017-03-28 08:58 UTC] graeme dot chapman at infinitycloud dot com
@requinix Makes sense. Think this needs a little update to the docs to clarify this though!
 [2017-03-28 10:28 UTC] derick@php.net
Supporting "+02:00" and the like, is new functionality since PHP 5.5. PHP 5.4 and earlier did not support this. We simply forgot to add this to the documentation.
 [2022-06-02 14:59 UTC] git@php.net
Automatic comment on behalf of derickr
Revision: https://github.com/php/doc-en/commit/071c7cace14d7f435981bf7f78a959d07be33571
Log: Fixed bug #74324: DateTimeZone supported timezone names
 [2022-06-02 14:59 UTC] git@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 18:01:29 2024 UTC