有没有办法使用 Zend Locale 转换时间,比如 17:00 到 5:00 pm?
我已经按原样尝试了文档中的方法(有错字),但它不起作用。它给出了错误'无法使用'dd.MM.yyyy'(M <> y)解析日期'13:44:42'
$locale = new Zend_Locale('de_AT');
if (Zend_Locale_Format::getTime('13:44:42',
array('date_format' =>
Zend_Locale_Format::STANDARD,
'locale' => $locale))) {
print "time";
} else {
print "not a time";
}
然后我尝试了一个两步法,首先获取当前语言环境的时间格式,然后在 getTime 函数中使用它。
$locale = new Zend_Locale('en_US');
$tf = Zend_Locale_Format::getTimeFormat($locale);
$test = Zend_Locale_Format::getTime('17:00', array('date_format' => $tf, 'locale' => $locale));
这会返回一个结果,但只会给我我所拥有的
array('date_format'=>'h:mm:ss a', 'locale'=>'en_US', 'hour'=>'17', 'minute'=>'00')
有什么东西可以将时间转换为我试图解析的实际语言环境吗?