options['nullValue']; } elseif (! $value instanceof DateTimeInterface) { $value = new DateTime((string) $value); } $formatValues = [ 'none' => IntlDateFormatter::NONE, 'short' => IntlDateFormatter::SHORT, 'medium' => IntlDateFormatter::MEDIUM, 'long' => IntlDateFormatter::LONG, 'full' => IntlDateFormatter::FULL, ]; $formatter = IntlDateFormatter::create( Locale::getDefault(), $formatValues[$this->options['dateFormat']], $formatValues[$this->options['timeFormat']], $value->getTimezone() ); return $formatter->format($value->getTimestamp()); } protected function configureOptions(OptionsResolver $resolver) { parent::configureOptions($resolver); $resolver ->setDefaults([ 'dateFormat' => 'short', 'timeFormat' => 'short', 'nullValue' => '', ]) ->setAllowedTypes('nullValue', 'string') ; return $this; } }