Sep8th
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.
Add comments
Recently
- 09.08 CakePHP default dateTime()
- 03.24 Extending CakePHP’s beforeFilter()
- 03.17 Rails-like Flash messages in CakePHP
- 03.08 CakePHP thumbnails with phpThumb
- 02.15 CakePHP model validation
- 02.10 CakePHP - saving dates in your model
- 09.19 Importing multiple pdf pages and documents into PDFlib - Part 2
- 09.18 Quick Link - Every CSS based layout you could want
- 09.04 Mongrel pid error fixed
- 09.04 Typo, Work in Progress