DATE_INTERVAL_FORMAT
Formats the interval
SYNTAX
date_interval_format ( DateInterval $object , string $format ) : string
PARAMETERS
object
A DateInterval object.
format
CHARACTER | DESCRIPTION | EXAMPLE |
---|---|---|
% | Literal % | % |
Y | Years, numeric, at least 2 digits with leading 0 | 01, 03 |
y | Years, numeric | 1, 3 |
M | Months, numeric, at least 2 digits with leading 0 | 01, 03, 12 |
m | Months, numeric | 1, 3, 12 |
D | Days, numeric, at least 2 digits with leading 0 | 01, 03, 31 |
d | Days, numeric | 1, 3, 31 |
a | Total number of days as a result of a DateTime::diff() or (unknown) otherwise | 4, 18, 8123 |
H | Hours, numeric, at least 2 digits with leading 0 | 01, 03, 23 |
h | Hours, numeric | 1, 3, 23 |
I | Minutes, numeric, at least 2 digits with leading 0 | 01, 03, 59 |
i | Minutes, numeric | 1, 3, 59 |
S | Seconds, numeric, at least 2 digits with leading 0 | 01, 03, 57 |
s | Seconds, numeric | 1, 3, 57 |
F | Microseconds, numeric, at least 6 digits with leading 0 | 007701, 052738, 428291 |
f | Microseconds, numeric | 7701, 52738, 428291 |
R | Sign "-" when negative, "+" when positive | -, + |
r | Sign "-" when negative, empty when positive | -, |
RETURN
Returns the formatted interval.
EXAMPLES
1
years: 1
months: 1
days: 1
hours: 1
minutes: 1
seconds: 1
2
years: 20
months: 0
days: 23
hours: 15
minutes: 25
seconds: 42