PHP 处理带毫秒的时间

PHP 处理格式为 2018-11-15T09:21:13.15823439Z 的时间, 将其转化为带毫秒的时间戳

可使用 DateTime 类的 format() 方法来处理

1 $time = new DateTime('2018-11-15T09:21:13.15823439Z');
2 
3 $timestamp = $time->format('U.u');
4 
5 echo $timestamp;
6 
7 // $timestamp = 1542270683.058934

U 表示格式化为 unix 时间戳

u 表示格式化为毫秒

关于 format 格式化参数说明, 可以参考 http://php.net/manual/zh/function.date.php

猜你喜欢

转载自www.cnblogs.com/mayzhi/p/9973390.html