php - Symfony2 and 1969/04/27 date -


i have form:

// appbundle\form\myformtype.php //... ->add('startdate', 'date', array(                    'widget'=>'single_text'         )) //.... 

everything works fine except when date 1969/04/27.


**message:** value not valid. **origin:** startdate **cause:** symfony\component\validator\constraintviolation  object(symfony\component\form\form).children[startdate] = 27/04/1969  **caused by:**  symfony\component\form\exception\transformationfailedexception  unable reverse value property path "startdate": date parsing failed: u_parse_error  **caused by:**  symfony\component\form\exception\transformationfailedexception  date parsing failed: u_parse_error 

i tested on versions 2.6 , 2.7 of symfony2. both problem same. tested in different applications , problem similar.

that's because use php intl. solved problem using symfony intl. here code use. in class datetimetolocalizedstringtransformer.php

use symfony\component\intl\dateformatter\intldateformatter;    class datetimetolocalizedstringtransformer extends basedatetimetransformer {      ....      ....      ....       /**      * returns preconfigured intldateformatter instance.      *      * @return intldateformatter      *      * @throws transformationfailedexception in case date formatter can not constructed.      */     protected function getintldateformatter()     {         $dateformat = $this->dateformat;         $timeformat = $this->timeformat;         $timezone = $this->outputtimezone;         $calendar = $this->calendar;         $pattern = $this->pattern;         //remove         //$intldateformatter = new \intldateformatter(\locale::getdefault(), $dateformat, $timeformat, $timezone, $calendar, $pattern);         //add         $intldateformatter = new intldateformatter('en', $dateformat, $timeformat, $timezone, $calendar, $pattern);          // new \intldateformatter may return null instead of false in case of failure, see https://bugs.php.net/bug.php?id=66323         if (!$intldateformatter) {             throw new transformationfailedexception(intl_get_error_message(), intl_get_error_code());         }          $intldateformatter->setlenient(false);          return $intldateformatter;     } } 

but works locale "en" until implemented other locales


Comments