8
I’m in trouble and I’m not finding any solution to fix it.
I have a date in this format: Wednesday, 30 April, 2014
and I want to save this date in the database on type datetime
.
So I’m trying to make the conversion for the guy datetime
, but I have a problem:
If the date is in English: Wednesday, 30 April, 2014
then mine echo
works, and shows the date in date time.
If the date is in English: Quarta-feira, 30 Abril, 2014
the echo
no longer works and I have this mistake: Call to a member function format() on a non-object
.
I’m doing the conversion with the Datetime class::
$data= DateTime::createFromFormat('l, j F, Y', 'Quarta-feira, 30 Abril, 2014');
echo $data->format('Y-m-d');
Someone’s had this problem before and you know how I can fix it?
Thank you very much, finally problem solved!! :)
– Mib
After all, I looked at the code and it looked like what I was looking for, but now that I’ve tested it, I’m making the same mistake!
– Mib