I have a model with such field:
/**
* @var datetimetz
*
* @ORM\Column(name="effective_from", type="datetimetz", nullable=false)
*/
private $effectiveFrom;
in the form builder I present it as:
->add('effectiveFrom', 'datetime', array(
'date_widget' => 'single_text',
'time_widget' => 'single_text',
'date_format' => 'Y-MM-dd',
'with_seconds' => true
))
So it is rendered as two different input fields.
Let’s suppose I’ve specified 2012-07-31 in the date field and 16:15:18 in the time field.
I press submit and var_dump() the entity. The bind date becomes 1970-07-31 16:15:18. And with any date only year is recognized in wrong way :-S
If I don’t change date and time widgets – then everything works as expected.
Any suggestions?
Well, it is symfony documentation bug.
yyyy(lower case) should be used.I’ve filled the bug https://github.com/symfony/symfony-docs/pull/1045 and I hope it will be fixed soon