MySQL PHP date formatting

Hi,

  1. I’m creating my first application using Yii (great stuff). I created a MySQL table with a date column and did the scaffolding (model + crud) for this table. To create a record the create view is displayed. I am able to enter a date in the generated textfield and save the record. However, I need to use the format YYYY-MM-DD because otherwise the date is not saved correctly.

I already found that MySQL does not support any other format than YYYY-MM-DD for date fields. So what’s the best approach to make the corresponding PHP (and generated HTML forms) work with f.e a MM-DD-YYYY format? I want to have the DD-MM-YYYY format in all of the generated views (create, update, show, list etc) without adapting to much code.

I’ld rather not do conversions for every date and datefield in my application. Is there any way to set the default date format for PHP and client side?

  1. Should I use another MySQL type for dates to make life easier?

  2. Does the Yii framework support this issue in some way?

  3. Any calendar extension to recommend also?

Thank you,

Rickert

see http://www.yiiframework.com/extension/i18n-datetime-behavior/

work for me

Thanks Horacio. I already stumbled on this extension. All extension zip files seem to be corrupt though, so I was not able to try this. I’ll let you know if it worked for me when the zip files are fixed.

try with the attachment

343

DateTimeI18NBehavior1.1.zip

I’ve been using DATETIME fields in MySQL filling them with date(‘c’). Seems to work just fine.