Date Format In Yii ?

Hello All, :)

i have some problem about date format that need to display in text and store to database.

Bellow date format that i need (some format):

  • DD/MM/YYYY

  • DD-MM-YYYY

  • YYYY/MM/DD

  • etc

and in database will be:

  • YYYY-MM-DD

is there Yii solutions about this ?

thank you

there is a "format" application component (Yii::app()->format) that you can use to format date. Just provide required configuration in your config file.

read more about what can be configured and how to call it here: http://www.yiiframework.com/doc/api/1.1/CFormatter

for converting back and forth when dealing with database reads and writes you could use afterFind and beforeSave handlers.

Hi friends!

Good pratice!

I didn’t know, about this app component to deal with formating. I was working with CDateFormatter class.

Thanks for help a newbee [size=2]![/size]

Great, thank you