I have a form within which a date is input in UK format, and I need to convert it to
yyyy-mm-dd
e.g. a date entered is: 31/03/2013
which I want to convert to '2013-03-31'
for database insert.
I'm using the following which bizarrely works only sometimes:
$dateInput = $mysqli->real_escape_string($_POST['date']);
$show_date = date('Y-m-d', strtotime($dateInput));
Is there a better way to do this?