Time\Duration::fromMicroseconds
(PHP 8 >= 8.6.0)
Creates a duration from a number of microseconds
Description
Creates a non-negative duration of microseconds microseconds. The value is normalized into whole seconds and nanoseconds, see the Time\Duration::$seconds and Time\Duration::$nanoseconds properties.
Parameters
microsecondsThe number of microseconds. Must be greater than or equal to
0.
Return Values
Returns a new Time\Duration object.
Errors/Exceptions
- If
microsecondsis negative, aValueErroris thrown.
Examples
Time\Duration::fromMicroseconds example
<?php
var_dump(\Time\Duration::fromMicroseconds(1_500_000));The above example will output:
object(Time\Duration)#1 (3) {
["seconds"]=>
int(1)
["nanoseconds"]=>
int(500000000)
["negative"]=>
bool(false)
}See Also
Time\Duration::fromSecondsTime\Duration::fromNanosecondsTime\Duration::fromMilliseconds