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
will
(Phpwindcn)
May 7, 2009, 8:33pm
2
Invalid date format, should use:
date('Y-m-d',strtotime($payment->paymentReceiveDate));
StErMi
(Stermi)
May 7, 2009, 10:35pm
3
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
mocapapa
(Mocapapa)
May 8, 2009, 12:12am
4
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