php 日期处理 DateTime

 

获取全部的时区php

print_r(timezone_abbreviations_list ());

 

获取毫秒级时间戳linux

// php7.1+ always has microseconds enabled, so we do not need this hack
if (PHP_VERSION_ID < 70100) {
  // 第一个参数:php 支持的日期和时间格式
$ts = DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true))); } else { $ts = new DateTime(null); } $ts->setTimezone(new DateTimeZone("PRC")); var_dump($ts->format("Y-m-d H:i:s.u")); // 2018-09-15 20:15:58.332000 win下只能够到三位,linux能够到六位

 

php支持的日期和时间格式php7

 

function utime()
{
    return (float) (vsprintf('%d.%06d', gettimeofday()));
}
相关文章
相关标签/搜索