I really like the strtotime()
function, but the user manual doesn\'t give a complete description of the supported date formats. strtotime(\'dd/mm/YYYY\')<
This workaround is simpler and more elegant than explode:
$my_date = str_replace("/", ".", $my_date);
$my_date = strtotime($my_date);
$my_date = date("Y-m-d", $my_date);
You don't have to know what format you're getting the date in, but if it comes with slashes they are replaced with full stops and it is treated as European by strtotime.