从时间到日期,没有时间在PHP [重复]

This question already has an answer here:

I have to convert this string date 2016-09-26 00:00:00.000 to the yyyy-mm-dd format without other characters.

Can you help me, please?

</div>

You can just use the DateTime class along with the format() method:

$d = new DateTime('2016-09-26 00:00:00.000');
echo $d->format('Y-m-d');

Try this:

$datetime = '2016-09-26 00:00:00.000';

$date = date('Y-m-d', strtotime('2016-09-26 00:00:00.000'));

you will get the only date part in 'yyyy-mm-dd' format.

$test = strtotime('2016-09-26 00:00:00.000');
$test1 = date('Y-m-d h:i', $test);
$array1 = explode(' ', $var);
$date_temp = $array1[0];