Issue when saving a date

I have a field in my form that is a straight text field for users to enter in a date in the format of "05/10/2009". The datatype in the database is set to Date.

When my save or update method is called I'm doing the following to convert the date to save in MySQL:

$payment->paymentReceiveDate=date('Y-mm-dd',strtotime($payment->paymentReceiveDate));

It never seems to save correctly, the value is always all 0's.

What is the best way to do this?

Thanks,

Ben

Invalid date format, should use:

date('Y-m-d',strtotime($payment->paymentReceiveDate));


Yii have no fault :) You have to save the date in the right mySQL date format.

I know that a right date format is YYYY-MM-DD :) I don’t know how many date format mysql accepts

Quote

Invalid date format, should use:
date('Y-m-d',strtotime($payment->paymentReceiveDate));


Yeah you are right. Just trying to echo the date as follows,



echo date('Y-mm-dd',strtotime('05/10/2009'));


It gives the result of



2009-0505-1010


Thanks, that seemed to fix it.

Ben