php gets the specific Y-m-d H:i:s time through millisecond timestamp?
For example, the millisecond timestamp is: 1492396179000
and the corresponding format is: 2017-04-17 10:29:39
ringa_lee2017-05-16 13:14:50
Just use substr to intercept the first ten digits of the millisecond timestamp. For example:
date_default_timezone_set('PRC');
$time = 1492396179000;
$time = substr($time,0,10);
$date = date('Y-m-d H:i:s',$time);
echo $date;
漂亮男人2017-05-16 13:14:50
date_default_timezone_set('PRC');
$mtimestamp = sprintf("%.3f", microtime(true)); // 带毫秒的时间戳
$timestamp = floor($mtimestamp); // 时间戳
$milliseconds = round(($mtimestamp - $timestamp) * 1000); // 毫秒
$datetime = date("Y-m-d H:i:s", $timestamp) . '.' . $milliseconds;
echo sprintf("%s -> %s", $mtimestamp, $datetime);