I dont know why I am getting this error or how to fix it.
Call to a member function format() on a non-object createFromFormat
Code:
$date = "30 Sep 2009";
$data['StartDate'] = DateTime::createFromFormat('d m Y', $date)->format('Y-m-d');
I want to convert it to standard MySql Date format.
The error is likely due to the fact that “m” is the code for two digit month–not textual representation, which is “M”.
Have you, by any chance, tried simply passing that string into the DateTime constructor? The format is one of the accepted ones per http://www.php.net/manual/en/datetime.formats.date.php .