ZF-11552: Zend_Date doesn't correctly parse timezones that contain underscores

Issue Type: Bug Created: 2011-07-12T16:50:52.000+0000 Last Updated: 2011-08-30T16:04:40.000+0000 Status: Open Fix version(s): Reporter: Jesse Patching (taeram) Assignee: Thomas Weidner (thomas) Tags: - Zend_Date

Related issues: Attachments:


Zend_Date does not correctly parse timezones which contain an underscore. Eg: America/New_York

Non-underscored timezones are parsed correctly. Eg: America/Denver


<pre class="highlight">
$date = new Zend_Date('2011-01-01 00:00:00 UTC');
echo $date->getTimezone()."\n"; // Correctly prints "UTC"

$date = new Zend_Date('2011-01-01 00:00:00 America/Denver');
echo $date->getTimezone()."\n"; // Correctly prints "America/Denver"

$date = new Zend_Date('2011-01-01 00:00:00 America/New_York');
echo $date->getTimezone()."\n"; // Incorrectly prints "UTC"

$date = new Zend_Date('2011-01-01 00:00:00 America/Cambridge_Bay');
echo $date->getTimezone()."\n";  // Incorrectly prints "UTC"

The restrictive regex responsible for the issue can be found in Zend_Date::getTimezoneFromString():

<pre class="highlight">
preg_match('/([[:alpha:]\/]{3,30})(?!.*([[:alpha:]\/]{3,30}))/', $zone, $match);

Proposed patch:

<pre class="highlight">
preg_match('/([[:alpha:]\/_]{3,30})(?!.*([[:alpha:]\/_]{3,30}))/', $zone, $match);


Posted by Christian Kaps (akkie) on 2011-08-30T13:08:05.000+0000

Are there any news from the developers. When will this bug be fixed? Does the proposed patch fix this bug?

We are port our application to other countries and this is a show stopper for our new release.

Posted by Jesse Patching (taeram) on 2011-08-30T16:04:40.000+0000

I'm using the proposed patch successfully in my project. I'm using the latest Zend 1.11 (revision 24425).

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.