IntlDateFormatter :: Parse返回dateparsing失败:U_PARSE_ERROR

我正在使用symfony2来处理我的应用程序。 在datetypes表单字段validation期间,symfony尝试parsing传入的stringdate值。出于某种原因,本地工作(运行MAMP&php 5.3.6),但在远程Fedora服务器上失败。 (PHP 5.3.8)。 这里有一些detils,我包括任何可能相关的东西。

当实例化一个新的IntlDateFormatter我正在使用

locale: en_US_POSIX date format: 2 time format: -1 timezone: America/Chicago calendar: 1 pattern: MM-dd-yyyy 

使用像11/21/2012这样的date在IntlDateFormatter上调用parsing

 $timestamp = $this->getIntlDateFormatter()->parse($value); 

这里是getIntl​​DateFormatter方法。

 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); } 

处理stringdate值转换为本地化date时间值的整个类在这里 …

这导致parsing失败,错误可以使用:intl_get_error_message()

以下是远程机器上phpinfo()的一些片段:

国际配置

日期配置

如果它有帮助…整个phpinfo()的截图….. http://f.cl.ly/items/3q2q2C3Z0b0K1a0F0c3F/phpinfo%20.png

我也面临这个问题,然后我深入搜索,发现日期格式是错误的。你应该选择这样的格式'format' => 'yyyy-MM-dd H:m'

所以这是完整的列表文件将此行添加到过滤器字段

 ->add('createdAt', 'doctrine_orm_datetime_range', array('field_type' => 'sonata_type_datetime_range'), null, array( 'widget' => 'single_text', 'format' => 'yyyy-MM-dd H:m', 'required' => false, 'attr' =>array('class' => 'datetimepicker')) ) 

然后以这种格式输入开始日期和结束日期2014-09-29 4:46

希望这将解决问题