This will give you a MySQL compatible time for each half hour.
for ($i=0; $i < 24; $i++) {
$hour = str_pad($i, 2, '0', STR_PAD_LEFT);
$time_options[$hour.':00:00'] = $hour.'\'00';
$time_options[$hour.':30:00'] = $hour.'\'30';
}
$form->input('time',array('type'=>'select','options'=>$time_options))
On Jan 19, 4:33 pm, leo <[email protected]> wrote:
> It really depends on the design of your form. You could use an HTML
> select element as a time chooser and only specify the half hours as
> options. You could round up (or down) automatically. You could do it
> by validation (php or javascript).
>
> On Jan 19, 12:39 pm, ChristineA <[email protected]> wrote:
>
> > Hi there,
>
> > I've been giving the user the option to insert the time into a form
> > like this:
> > <?php echo $form->input('time');?>
>
> > Now the user has a choice of 60 minutes. I've been trying to limit the
> > choice to 30 minutes leaps. So it should only be possible to choose
> > 5:30, 6:00, 6:30 and so on. Is there any elegant way of doing this or
> > do I have to write a huge html part listing every possible month, hour
> > and minute?
>
> > Thanks!
>
> > Christine
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---