views:

116

answers:

1

Hey all I'm trying to validate a 'time' field using Zend Framework.

The docs seem to be pointing out that the following:

$tstarttime =  $form->createElement('text','t_start_time');
$tstarttime->setRequired(true)
    ->setLabel('Start Time')
    ->addValidator(new Zend_Validate_Date('H:i'));

I've tried this but no luck. Any ideas or alternative ways to validate a time in the format of HH:MM (H:i in php)

Thanks all!

A: 

Try this

 $tstarttime =  $form->createElement('text','t_start_time');
 $tstarttime->setRequired(true)
      ->setLabel('Start Time')
      ->addValidator(new Zend_Validate_Date(array("format" => 'H:i')));
jakenoble