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


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

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


$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():

preg_match('/([[:alpha:]\/]{3,30})(?!.*([[:alpha:]\/]{3,30}))/', $zone, $match);

Proposed patch:

preg_match('/([[:alpha:]\/_]{3,30})(?!.*([[:alpha:]\/_]{3,30}))/', $zone, $match);


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.

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