Basically I have a date a user selects, that is formatted as follows:
01-12-2013 (dd-mm-yyyy)
And I need to format it into a yyyy-mm-dd format for the DB as its a date type like this:
2013-12-01
I store my date in a variable, lets call it $date
I have tried using the createFromFormat function like this:
$processdate = DateTime::createFromFormat('dd-mm-yy', $date);
echo $processdate->format('yy-mm-dd');
But I get an error saying that:
Fatal error: Call to a member function format() on a non-object
Can someone tell me how I am not using it correctly please?