I have a problem and I can not find a solution to fix it.
I have a date in this format: Wednesday, April 30, 2014
and I want to save this date in the database in type datetime
.
So I am trying to convert to type datetime
, but I have a problem:
If the date is in English : Wednesday, 30 April, 2014
so my echo
works, and shows the date in date time.
If the date is in Portuguese: Quarta-feira, 30 Abril, 2014
echo
no longer works and I get this error: Call to a member function format() on a non-object
.
I'm doing the conversion with the class DateTime ::
$data= DateTime::createFromFormat('l, j F, Y', 'Quarta-feira, 30 Abril, 2014');
echo $data->format('Y-m-d');
Has anyone ever had this problem and know how I can solve it?