PHP convert date format dd/mm/yyyy => yyyy-mm-dd
Have a look at he solution below,
Basically, in the format of m/d/y or d-m-y date are rephrase by looking at the separator between the many components. The American m/d/y is assumed incase the separator is a slash that means /, ; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed. For additional information.
Here is an example for use the default date function in code.
$var = "20/04/2012"; echo date("Y-m-d", strtotime($var) );
If suppose PHP does not work with dd/mm/yyyy format well use the below solution,
$var = '20/04/2012'; $date = str_replace('/', '-', $var); echo date('Y-m-d', strtotime($date));