I'm trying to format a date field so when I use it for display, it shows up in MM/DD/YYYY format, and I'm assuming I can set that up in the model somewhere
Models should take care of presenting the data as your application wants it. Helpers should be used to format your data the way you want it output to the user. Here is an example using dates : 1. I want the date stored as a DATETIME field in the database. This is practical because it means it can be edited by hand should the need arise. 2. However, I want my application to use it as a unix timestamp - because it's more practical to manipulate and less bug-prone. 3. Finaly, I want the date displayed as "Thursday the 28th of December 2006" type of string to the application user. To achieve these aims I will do the following : 1. Store the field as a DATETIME in the database 2. Use the Model callback "afterFind" to change the field to a unix timestamp. 3. Use a Helper to display the date in the format you like (see Samuel's post) Anselm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~----------~----~----~----~------~----~------~--~---
