Calculate the interval between two dates, then format the interval:
The date_interval_format() function is an alias of DateInterval::format().
DateInterval::format() function is used to format time intervals.
DateInterval::format( format);
parameter | describe |
---|---|
format | Required. Specify the format. The format parameter string can use the following characters: % - Literal % Y - Year, at least 2 digits with leading zeros (e.g. 03) y - year (e.g. 3) M - month, with leading zeros (e.g. 06) m - month (e.g. 6) D - day, with leading zeros (e.g. 09) d - day (e.g. 9) a - the total number of days between two dates as determined by date_diff() H - hour, with leading zeros (e.g. 08, 23) h - hour (e.g. 8, 23) I - cents, with leading zeros (e.g. 08, 23) i - points (e.g. 8, 23) S - seconds with leading zeros (e.g. 08, 23) s - seconds (e.g. 8, 23) R - the sign "-" when negative and "+" when positive r - the sign "-" when negative and empty when positive Note: Each format string must be prefixed with a % character! |
Return value: | Returns the formatted time interval. |
---|---|
PHP version: | 5.3+ |