array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.hrtime.php', 1 => 'hrtime', ), 'up' => array ( 0 => 'ref.misc.php', 1 => '杂项 函数', ), 'prev' => array ( 0 => 'function.highlight-string.php', 1 => 'highlight_string', ), 'next' => array ( 0 => 'function.ignore-user-abort.php', 1 => 'ignore_user_abort', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/misc/functions/hrtime.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 7 >= 7.3.0, PHP 8)
hrtime — 获取系统的高精度时间
从任意时间点开始统计,返回系统的高精度时间(high resolution time)。 获取的时间戳为单调时间,无法被用户调整。
参数 as_number
为 false 时,返回的整型数组格式为
[seconds, nanoseconds]。否则会以 int (64 位平台)或
float (32 位平台)返回奈秒(nanoseconds)。失败时返回 false
。
示例 #1 hrtime() 的用法
<?php
echo hrtime(true), PHP_EOL;
print_r(hrtime());
?>
以上示例的输出类似于:
10444739687370679 Array ( [0] => 10444739 [1] => 687464812 )