Jelix 1.8.12

jDuration
in package

Utility to manipulate durations between two instants.

Tags
subpackage

utils

Table of Contents

$days  : mixed
$months  : mixed
$seconds  : mixed
__construct()  : mixed
Construct a new duration.
add()  : mixed
Add a duration to the current duration.
mult()  : mixed
Multiply the current duration by an integer.

Properties

Methods

__construct()

Construct a new duration.

public __construct(array<string|int, mixed>|int $init) : mixed

You can specify the duration as a number of seconds, or as an associative array which may contain the keys "year", "month", "day", "hour", "minute" and "second". The former method defines an absolute duration (it will always add the same number of seconds to any given date/time), while the latter defines a relative duration (a duration of one month will for example represent different amounts of time depending on the start date).

This class represents years as 12 months, minutes as 60 seconds and hours as 3600 seconds. There is no general conversion between months and days, nor between days and hours (because of DST).

Parameters
$init : array<string|int, mixed>|int

representation of the duration as an absolute number of seconds, or an array

Tags
Return values
mixed

add()

Add a duration to the current duration.

public add(jDuration $data) : mixed
Parameters
$data : jDuration

the duration value

Tags
Return values
mixed

mult()

Multiply the current duration by an integer.

public mult(int $scale) : mixed
Parameters
$scale : int

the scaling integer

Tags
Return values
mixed

Search results