Date Formating

Hi,

Another Newbie question.

My client requested that all dates should be in format ‘dd-mm-yy’. What is the best way to approach it in Yii? I have created beforeUpdate method where I convert date ‘22-06-2011’ into ‘2011-06-22’ before database is updated. I have also formatted gridview column, but in my _view, when data is retrieved, I see 2011-06-22 00:00:00 as I am using CActiveForm.textField. How to resolve it?

Thank you

Jerzy

Like you added beforeUpdate()… you can change the database date format to a custom one in afterFind()

Hi,

Thank you, it works. On top of it, for a new record, I had to add following code to controller ( when Post is not present )

if( $model->isNewRecord ) $model->ServiceDate = null;

Otherwise I had ‘0000-00-00 00:00:00’ when entering page for new record

I do not know if this is proper way to do it. I mean should I do something in the model instead of controller?