Question

In my form I want to have the time in 24h mode. In datetime specification in the cookbook there is a parameter timeFormat that accepts 12, 24 or null values but when I try to add it inside the parameters of the form input it doesn't work. Still I have the 12h mode with am/pm select. The dateFormat works OK.

My view is:

echo $this->Form->input('Reservation.arrival', array(
            'label'=>'Check IN', 
            'div'=>'clear IconDate',
            'timeFormat ' => '24',//doesn't work
            'dateFormat' => 'DMY',
            'minYear' => date('Y') - 0,
            'maxYear' => date('Y') + 1 ,
            )
        );

I am using CakePHP 1.3.

Thanks!

Was it helpful?

Solution

You have a space in your key 'timeFormat '. Make sure you remove the trailing space at the end, and it should work just fine. :)

Before:

'timeFormat ' => '24'

After:

'timeFormat' => '24'

OTHER TIPS

 $this->Form->input('tob',array('selected'=>'06:35:00','label'=>'Time Of birth','type'=>'time','timeFormat'=>'24' )); 

This way selected value can be set. 'selected' attribute is there so set default time in select boxes

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top