php 日期时间类型带毫秒

<?php
        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);//1523856374.820 => 2018-04-16 13:26:14.820

?>
原文地址:https://www.cnblogs.com/phpper/p/8855426.html