By default a Zend Framework date validator uses the date format yyyy-MM-dd
:
$dateValidator = new Zend_Validate_Date();
But I want to add hour and minute validation. In other words, I want to require the user to enter the hour and minute. But the following does not work:
$dateValidator = new Zend_Validate_Date('yyyy-MM-dd hh:ii');
If I enter 2010-02-01
, I get an error saying that the date doesn't fit the format. If I enter 2010-02-01 3
, it doesn't complain. What's it's doing is assuming that the user means 2010-02-01 03:00
rather than enforcing that the user enters the date in the given format.
How can I enforce that the date must be entered in the given format?