Time\Duration::fromMinutes

(PHP 8 >= 8.6.0)

Time\Duration::fromMinutes — Creates a duration from a number of minutes

Descrizione

public static function Time\Duration::fromMinutes(int $minutes): Time\Duration

Creates a non-negative duration of minutes minutes. The value is normalized into whole seconds and nanoseconds, see the Time\Duration::$seconds and Time\Duration::$nanoseconds properties.

Elenco dei parametri

minutes

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

Valori restituiti

Returns a new Time\Duration object.

Errori/Eccezioni

Esempi

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

<?php
var_dump(\Time\Duration::fromMinutes(90));

try {
    \Time\Duration::fromMinutes(-1);
} catch (ValueError $e) {
    echo $e->getMessage(), PHP_EOL;
}

Il precedente esempio visualizzerà:

object(Time\Duration)#1 (3) {
  ["seconds"]=>
  int(5400)
  ["nanoseconds"]=>
  int(0)
  ["negative"]=>
  bool(false)
}
Time\Duration::fromMinutes(): Argument #1 ($minutes) must be greater than or equal to 0

Vedere anche:

+add a note

User Contributed Notes

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