If you want to change the format of the value of a DateTime element, the easiest way to do this in your Form class is to do this:
$this->add(array( 'name' => 'next_appointment', 'type' => 'Zend\Form\Element\DateTime', 'options' => array( 'label' => 'Next callback time', ), 'attributes' => array( 'min' => '1 Jan 2013, 00:00', ), )); $this->get('next_appointment')->setFormat('j M Y, H:i');
The two things to note:
- You can't set the format within the array - it has to be via a setFormat() call.
- If you change the format, you must set the min attribute in the same format, as otherwise it will try to set it with the hardcoded string of '1970-01-01T00:00Z' which will not work with your specified format.