php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #54210 provide a function to canonicalize timezone strings
Submitted: 2011-03-09 23:28 UTC Modified: 2011-03-10 14:54 UTC
From: giorgio dot liscio at email dot it Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.3.5 OS: all
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: giorgio dot liscio at email dot it
New email:
PHP Version: OS:

 

 [2011-03-09 23:28 UTC] giorgio dot liscio at email dot it
Description:
------------
hi, it is needed a function that converts "europe/rome" in "Europe/Rome"

for example the intl module (ICU) of php 5.3 does not accept "europe/rome" as timezone, but only "Europe/Rome", with uppercase first letters

thank you


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-03-10 07:16 UTC] scottmac@php.net
-Status: Open +Status: Bogus
 [2011-03-10 07:16 UTC] scottmac@php.net
$tz = implode('/', array_map('ucfirst', explode('/', $tz)));

No need to add a new function for this, and if the timezone is set by your app 
then you should probably store it in the correct format.
 [2011-03-10 07:16 UTC] scottmac@php.net
$tz = implode('/', array_map('ucfirst', explode('/', $tz)));

No need to add a new function for this, and if the timezone is set by your app 
then you should probably store it in the correct format.
 [2011-03-10 14:54 UTC] dtajchreber@php.net
Not that it's hard to implement in userland code but it'd be nice if the 
DateTimezone class gave the timezone name in canonical form... I don't see why 
it shouldn't either?

$dt = new DateTimezone('america/chicago');
var_dump($dt->getName()); /* string(15) "america/chicago" */

vs. 

$dt = new DateTime();
var_dump($dt->getTimezone()->getName()); /* string(16) "Australia/Sydney" */
 [2011-03-11 15:53 UTC] giorgio dot liscio at email dot it
exact, it is not a problem implement this in the user space

but it is nonsense since some php functions requires a canonical tz string
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 21:01:35 2025 UTC