获取所有的时区

print_r(timezone_abbreviations_list ());

 

获取毫秒级时间戳

// 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支持的日期和时间格式

 

function utime()
{
    return (float) (vsprintf('%d.%06d', gettimeofday()));
}

 

相关文章:

  • 2021-11-28
  • 2022-12-23
  • 2022-01-07
  • 2021-12-10
  • 2022-12-23
  • 2021-12-19
  • 2021-11-29
猜你喜欢
  • 2021-12-13
  • 2021-10-29
  • 2021-09-14
  • 2022-12-23
相关资源
相似解决方案