Introduction
Represents a 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
DateTimeImmutable's and
DateTime's constructors support.
More specifically, the information in an object of the
DateInterval class is an instruction to get from
one date/time to another date/time. This process is not always reversible.
A common way to create a DateInterval object
is by calculating the difference between two date/time objects through
DateTimeInterface::diff().
How the time part of an interval, that is hours, minutes, seconds and
microseconds, is applied when the interval is added to, or subtracted
from, a date/time object depends on how the interval was created. For an
interval created with DateInterval::__construct()
the time part covers elapsed time, whereas for an interval created with
DateInterval::createFromDateString(), or returned
by DateTimeInterface::diff(), it increments or
decrements the individual component values. The date part, that is years,
months and days, always increments or decrements the individual component
values. The two therefore only give a different result when a
timezone transition falls within the time part of the interval; see
Date/Time Arithmetic.
Since there is no well defined way to compare date intervals,
DateInterval instances are
incomparable.