DateInterval (class)
The DateInterval class
Introduction
(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.
Class synopsis
public static DateInterval createFromDateString ( string $time )
public string format ( string $format )}
Properties
- y
-
Number of years.
- m
-
Number of months.
- d
-
Number of days.
- h
-
Number of hours.
- i
-
Number of minutes.
- s
-
Number of seconds.
- invert
-
Is 1 if the interval represents a negative time period and 0 otherwise. See DateInterval::format().
- days
-
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.
Table of Contents
- DateInterval::__construct — Creates a new DateInterval object
- DateInterval::createFromDateString — Sets up a DateInterval from the relative parts of the string
- DateInterval::format — Formats the interval
© 1997–2017 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://secure.php.net/manual/en/class.dateinterval.php