PHP获取一个毫秒级的时间戳

时间:2020-11-27 11:53:58   收藏:0   阅读:30

主要是通过,microtime() 函数返回当前 Unix 时间戳的微秒数,格式化如下方法:

    /**
     * 获取一个毫秒级的时间戳 13位
     * 1604563860556
     * @return void
     */
    function millisecondWay(){
        list($s1, $s2) = explode(‘ ‘, microtime());
        return (float)sprintf(‘%.0f‘, (floatval($s1) + floatval($s2)) * 1000);
    }

结果为一个13位时间戳    1604563860556

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!