CKTIS / PHP
hrtime()
Measure intervals using a monotonic clock with an arbitrary origin.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
hrtime(bool $as_number = false): array|int|float|falseMeasure intervals using a monotonic clock with an arbitrary origin. The default pair holds whole seconds and remaining nanoseconds. With true the count is nanoseconds, returned as an int on 64-bit platforms and a float on 32-bit platforms. Failure returns false.
Signature
hrtime(bool $as_number = false): array|int|float|false
Example output
[true,2,true]
Examples
<?php
$start=hrtime(true); $pair=hrtime(); $end=hrtime(true);
echo json_encode([$end >= $start,count($pair),$pair[1] >= 0 && $pair[1] < 1000000000]);
Result
[true,2,true]