CakePHP default dateTime()
In the FormHelper class of Cake 1.2 there’s a method for generating fields for a datetime. It is not documented very well but you can pass a timestamp into the “selected” parameter and it will default the dropdowns to the date and time of that timestamp.
For instance, if you make this call:
echo $form->dateTime('GiftCard.expire','MDY','NONE',strtotime('+1 month'));
it will result in three select fields; Month, Day, Year; and they will be defaulted to one month from today. strtotime(’+1 month’) returns a timestamp corresponding one month from today.
About this entry
You’re currently reading “CakePHP default dateTime(),” an entry on ShaBaDeeHoob
- Published:
- 09.08.07 / 11am
- Category:
- CakePHP
- Tags:
- CakePHP, dateTime(), FormHelper
No comments
Jump to comment form | comments rss [?] | trackback uri [?]