class DateInterval (View source)

Representation of date interval. A date interval stores either a fixed amount of time (in years, months, days, hours etc) or a relative time string in the format that DateTime's constructor supports.

Properties

int $y

Number of years

int $m

Number of months

int $d

Number of days

int $h

Number of hours

int $i

Number of minutes

int $s

Number of seconds

float Since: 7.1.0
$f

Number of microseconds

int $invert

Is 1 if the interval is inverted and 0 otherwise

int|false $days

Total number of days the interval spans. If this is unknown, days will be FALSE.

Methods

__construct(string $duration)

No description

string
format(string $format)

Formats the interval

static DateInterval|false
createFromDateString(string $datetime)

Sets up a DateInterval from the relative parts of the string

void
__wakeup()

No description

static 
__set_state($an_array)

No description

array
__serialize()

No description

void
__unserialize(array $data)

No description

Details

__construct(string $duration)

No description

Parameters

string $duration

Exceptions

DateMalformedIntervalStringException

string format(string $format)

Formats the interval

Parameters

string $format

Return Value

string

static DateInterval|false createFromDateString(string $datetime)

Sets up a DateInterval from the relative parts of the string

Parameters

string $datetime

Return Value

DateInterval|false

Returns a new https://www.php.net/manual/en/class.dateinterval.php DateInterval instance on success, or FALSE on failure.

void __wakeup()

No description

Return Value

void

static __set_state($an_array)

No description

Parameters

$an_array

array __serialize()

No description

Return Value

array

void __unserialize(array $data)

No description

Parameters

array $data

Return Value

void