PHP生成13位数的时间戳,如mktime

use*_*156 3 php timestamp

可能重复:
php从日期字符串中获取microtime

出于特定目的,我需要获得日期/时间的13位数时间戳,但我找不到解决方案.

与PHP中的mktime一样,我们可以得到一个10位数的时间戳

echo mktime($hour, $minute, $second, $month, $day, $year);
Run Code Online (Sandbox Code Playgroud)

这输出像1346689283.

那么13位数的时间戳呢?PHP本身能够生成这样的时间戳吗?

Ren*_*Pot 9

你在找 microtime()

http://php.net/microtime

如果要从特定日期创建microtime,只需添加即可000.因为最后,微量时间只有1秒.


Mih*_*rga 8

制作毫秒:

$milliseconds = round(microtime(true) * 1000);
echo date("Y-m-d",($milliseconds/1000));
Run Code Online (Sandbox Code Playgroud)