我正在为我的应用程序使用 symfony2。在日期类型表单字段验证期间,symfony 尝试解析传入的字符串日期值。由于某种原因,这在本地工作(运行 MAMP 和 php 5.3.6)但在我们的远程 Fedora 服务器上失败。(PHP 5.3.8)。这里有一些细节,我包括任何可能相关的东西。
实例化我正在使用的新 IntlDateFormatter 时
locale: en_US_POSIX
date format: 2
time format: -1
timezone: America/Chicago
calendar: 1
pattern: MM-dd-yyyy
使用像 11/21/2012 这样的日期在 IntlDateFormatter 上调用Parse
$timestamp = $this->getIntlDateFormatter()->parse($value);
这是 getIntlDateFormatter 方法。
protected function getIntlDateFormatter()
{
$dateFormat = $this->dateFormat;
$timeFormat = $this->timeFormat;
$timezone = $this->outputTimezone;
$calendar = $this->calendar;
$pattern = $this->pattern;
return new \IntlDateFormatter(\Locale::getDefault(), $dateFormat, $timeFormat, $timezone, $calendar, $pattern);
}
处理将字符串日期值转换为本地化日期时间值的整个类都在这里...
这会导致解析失败,可以使用以下方法访问错误:intl_get_error_message()
以下是远程机器上 phpinfo() 的一些片段:
如果它有帮助......整个phpinfo()的截图...... http://f.cl.ly/items/3q2q2C3Z0b0K1a0F0c3F/phpinfo%20.png