PHP将mm-dd-yyyy转换为yy-mm-dd


php covert mm-dd-yyyy to yyyy-mm-dd

我正在尝试将此日期格式mm-dd-yyyy转换为yyyy-mm-dd我正在使用strtotime函数,但它没有正确转换。日期(Y-m-d, strtotime (' 06-15-2014 '))

以这种格式返回日期1970-01-01 01:00:00

字符串函数也可以。

$in = "05-14-2004"; // why would you even write dates like this?
$out = substr($in,-4)."-".substr($in,5);