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?
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?
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];
© 2022 - 2024 — McMap. All rights reserved.
$date = preg_replace("/\s{1}\d{2}:\d{2}\:\d{2}/",'',$datetime);
– Luigi