Chaning ActiveRecord Data on get/set?

I am just wondering the best way to go about changing the time format, I don’t want to require my users to use military time.

Hi,

i’ve added a CActiveRecordBehavior once to convert mysql date representation to the german date format and to allow the user to input different shorter formats like dmyy instead of dd.mm.yyyy …

Don’t know whether this is the best way because i had to implement five events to convert the data back and forth, but it did the job :D

regards

Yii provides CDataTime formatter for display dates and time in local format.




Yii::app()->dateFormatter->formatDateTime( strtotime($date));



You can use this line of code, you can write an helper for be more confortable or you can write a behavior that authomatically format the date.

thanks guys, yea i think a behavior is the way to go… just found out about the timestampbehavior… what a great idea.