如何将日期mdy格式转换为ymd格式? [重复]

This question already has an answer here:

Hi all i want to convert mdy format of date to ymd format

$todate = '03-31-2016;

I am using this code to convert it

$todate = date("Y-m-d", strtotime($todate));

This code gives me output

1969-12-31

so whats the right way to do it?

Thanks

</div>

Try this code

$date = '03-31-2016;
$todate = date("Y-m-d", strtotime($date));