我在 Ubuntu 上运行 ZF 1.9.4 和 PHP 5.2.10,并且能够重现您遇到的完全相同的问题。作为好奇的类型,我做了一点挖掘。在 isDate 的代码中,首先调用伴随类 Zend_Locale_Format 中的 getDate。这是一个 try-catch 循环,所以在 catch 部分,我让它将异常转储到 stdout。这是异常转储向我展示的内容:
带有消息“无法解析日期”的异常“Zend_Locale_Exception”
'2009-11-06T04:26:46-08:00' 在 /usr/share/php/libzend-framework-php/Zend/Locale/Format.php:995 中使用 'dd mm yy' (dy)'
堆栈跟踪:
#0 /usr/share/php/libzend-framework-php/Zend/Locale/Format.php(1116): Zend_Locale_Format::_parseDate('2009-11-06T04:2...', 数组)
#1 /usr/share/php/libzend-framework-php/Zend/Date.php(4583): Zend_Locale_Format::getDate('2009-11-06T04:2...', 数组)
#2 {censored}/testbed/test.php(26): Zend_Date::isDate('2009-11-06T04:2...', 'c')
#3 {主要}
对这个异常做一个 var_dump 更能说明那些不透明的数组。它们中的每一个都包含以下内容:
数组(4){
[“地区”]=>
字符串(5)“en_US”
["date_format"]=>
string(8) "dd mm yy"
["format_type"]=>
string(3) "iso"
["fix_date"]=>
bool(false)
}
So, date_format doesn't look right at all. It should be "YYYYMMDD'T'hh:mm:ssP," or something like that, in PHP date formatting lingo (I quoted the T, since it's the literal 'T' and not a timezone abbreviation). Granted, PHP just abbreviates it as 'c'.
Strange. So where in the world is it getting this date format? From _getLocalizedToken:
protected static function _getLocalizedToken($token, $locale)
{
switch($token) {
case self::ISO_8601 :
return "dd mm yy";
break;
...
That format looks completely wrong, given the output that ISO_8601 produces.
I would probably check with the people on the appropriate Zend list, but at first glance, this looks like something worthy of a bug report. Maybe they just don't support checks this particular type of date string yet?