PHP输出毫秒时间戳

代码:

<?php
list($msec, $sec) = explode(' ', microtime());
$msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
echo $msectime;

?>

输出:

1555923393483

封装成一个方法:

public static function msectime()
{
    list($msec, $sec) = explode(' ', microtime());

    return (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
}

 

posted @ 2019-04-22 17:16  凌雨尘  阅读(1446)  评论(0编辑  收藏  举报