Issues

ZF-12390: Long Timezones in Zend_Date constructor ignored with custom date format

Description

When creating a date in a specific timezone using a custom date string and format specifier, if the timezone contains underscore or dashes, the timezone is ignored.


date_default_timezone_set('Europe/London');
$customDateString = '2/9/2012 13:11:00 America/Los_Angeles';
$customFormat = 'd/M/yyyy H:m:s zzzz';
$date = new Zend_Date($customDateString, $customFormat);
echo $date->toString(Zend_Date::RFC_850) . PHP_EOL;
// Expected Result: Sunday, 02-Sep-12 13:11:00 America/Los_Angeles
//   Actual Result: Sunday, 02-Sep-12 13:11:00 Europe/London

/**
 * Workaround
 */
$date = new Zend_Date;
$date->setTimezone('America/Los_Angeles');
$date->set($customDateString, $customFormat);
echo $date->toString(Zend_Date::RFC_850) . PHP_EOL;
// Returns: Sunday, 02-Sep-12 13:11:00 America/Los_Angeles

When creating a date using any other timezone that matches /[:alpha:]\/[:alpha:]/ there is no issue.

Comments

This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit: https://github.com/zendframework/zf1/issues/2