(PHP 5 >= 5.3.0, PHP 7)
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 DateTime's constructor supports.
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().
public static createFromDateString ( string $datetime ) : DateInterval|false
public format ( string $format ) : string}
Number of years.
Number of months.
Number of days.
Number of hours.
Number of minutes.
Number of seconds.
Number of microseconds, as a fraction of a second.
Is 1
if the interval represents a negative time period and 0
otherwise. See DateInterval::format().
If the DateInterval object was created by DateTime::diff(), then this is the total number of days between the start and end dates. Otherwise, days will be false
.
Before PHP 5.4.20/5.5.4 instead of false
you will receive -99999 upon accessing the property.
Version | Description |
---|---|
7.1.0 | The f property was added. |
© 1997–2020 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/class.dateinterval.php