Time\Duration::fromMicroseconds

(PHP 8 >= 8.6.0)

Time\Duration::fromMicroseconds — Creates a duration from a number of microseconds

Descrizione

public static function Time\Duration::fromMicroseconds(int $microseconds): Time\Duration

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.

Elenco dei parametri

microseconds

The number of microseconds. Must be greater than or equal to 0.

Valori restituiti

Returns a new Time\Duration object.

Errori/Eccezioni

  • If microseconds is negative, a ValueError is thrown.

Esempi

Example #1 Time\Duration::fromMicroseconds() example

<?php
var_dump(\Time\Duration::fromMicroseconds(1_500_000));

Il precedente esempio visualizzerà:

object(Time\Duration)#1 (3) {
  ["seconds"]=>
  int(1)
  ["nanoseconds"]=>
  int(500000000)
  ["negative"]=>
  bool(false)
}

Vedere anche:

+add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top