hrtime

(PHP 7 >= 7.3.0, PHP 8)

hrtime獲取系統(tǒng)的高精度時(shí)間

說(shuō)明

hrtime(bool $get_as_number = false): mixed

從任意時(shí)間點(diǎn)開(kāi)始統(tǒng)計(jì),返回系統(tǒng)的高精度時(shí)間(high resolution time)。 獲取的時(shí)間戳為單調(diào)時(shí)間,無(wú)法被用戶調(diào)整。

參數(shù)

get_as_number

array 還是數(shù)字返回高精度時(shí)間。

返回值

參數(shù) get_as_number 為 false 時(shí),返回的整型數(shù)組格式為 [seconds, nanoseconds]。 否則會(huì)以 int (64 位平臺(tái))或 float (32 位平臺(tái))返回奈秒(nanoseconds)。

范例

示例 #1 hrtime() 的用法

<?php
echo hrtime(true), PHP_EOL;
print_r(hrtime());
?>

以上例程的輸出類(lèi)似于:

10444739687370679
Array
(
    [0] => 10444739
    [1] => 687464812
)

參見(jiàn)