php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66845 timezone_open
Submitted: 2014-03-07 13:33 UTC Modified: 2014-03-07 15:17 UTC
From: thekid@php.net Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.6.0alpha3 OS: Windows 7
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: thekid@php.net
New email:
PHP Version: OS:

 

 [2014-03-07 13:33 UTC] thekid@php.net
Description:
------------
timezone_open() behaviour has changed between PHP 5.5 and PHP 5.6

Test script:
---------------
$ php -ddate.timezone=Europe/Berlin -r 'var_dump(timezone_open("CEST"));'


Expected result:
----------------
object(DateTimeZone)#1 (2) {
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(13) "Europe/Berlin"
}


Actual result:
--------------
object(DateTimeZone)#1 (2) {
  ["timezone_type"]=>
  int(2)
  ["timezone"]=>
  string(4) "CEST"
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-03-07 14:39 UTC] derick@php.net
-Status: Open +Status: Not a bug
 [2014-03-07 14:39 UTC] derick@php.net
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

Yes, this is a bug fix. If you want to use Europe/Berlin, you need to use Europe/Berlin.

PHP 5.6 adds supports for using "type 1" (+03:00) and "type 2" (CEST/CET) as timezone object, where previously PHP wanted to be nice and allow the use of the deprecated abbreviations to be "upgraded" to Timezone Identifiers.
 [2014-03-07 14:50 UTC] thekid@php.net
-Status: Not a bug +Status: Re-Opened
 [2014-03-07 14:50 UTC] thekid@php.net
@derick - what you can't see as my reproducing script doesn't include it is that the "deprecated" identifier is returned from a call to timezone_transitions_get() in the first place:

php -ddate.timezone=Europe/Berlin -r 'var_dump(timezone_transitions_get(timezone_open("Europe/Berlin")));'
array(145) {
  ...
  [143]=>
  array(5) {
    ["ts"]=>
    int(2121901200)
    ["time"]=>
    string(24) "2037-03-29T01:00:00+0000"
    ["offset"]=>
    int(7200)
    ["isdst"]=>
    bool(true)
    ["abbr"]=>
    string(4) "CEST"
  }
  [144]=>
  array(5) {
    ["ts"]=>
    int(2140045200)
    ["time"]=>
    string(24) "2037-10-25T01:00:00+0000"
    ["offset"]=>
    int(3600)
    ["isdst"]=>
    bool(false)
    ["abbr"]=>
    string(3) "CET"
  }
}

One could regard this as a bug in that function then.
 [2014-03-07 15:17 UTC] derick@php.net
-Status: Re-Opened +Status: Not a bug
 [2014-03-07 15:17 UTC] derick@php.net
Abbreviations are only for display purposes. Do not do calculations with them. CEST doesn't necessarily always mean the same. The example is better with "EDT" as that is used in locations with different UTC offsets (US, Australia f.e.).

The project where this caused problems for you, should never have used $last['abbr'].
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 12:00:02 2026 UTC