Symfony datetime field format Symfony datetime field format symfony symfony

Symfony datetime field format


Have you tried the following date_format in your datetime definition?

'yyyy-MM-dd HH:mm'

instead of what you have now:

'yyyy-MM-dd HH:i'

I think you're mixing PHP date format options with the RFC format options the symfony form builder expects, according to the documentation. Peruse the accepted RFC datetime formats to see how to tweak it.


You should use the format option which accepts HTML5 DateTime format.

$builder->add(    'beginDate',    'datetime',    array(        'widget' => 'single_text',        'format' => 'yyyy-MM-dd  HH:mm'    ))

The format option should be used instead of date_format when using widget = single_text.


Why don't you try this?

    $builder        ->add('beginDate', 'date', array(            'widget' => 'single_text',            'format' => 'yyyy-MM-dd H:mm',        ));