date_interval_format()
date_interval_format() — Alias of DateInterval::format().
Built-in function of PHP 8.5. The manual lists it as available in PHP 5 >= 5.3.0, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
date_interval_format() is an alias of DateInterval::format(): same parameters, same return value.
Signature
DateInterval::format(string $format): string
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $format | string | The following characters are recognized in the format parameter string. Each format character must be prefixed by a percent sign (%). format character Description Example values % 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 ... |
Return value
Returns the formatted interval.
Example
A runnable snippet:
$interval = new DateInterval('P2Y4DT6H8M'); echo $interval->format('%d days');
Output:
4 days
All PHP 8.5 built-in functions
Reference card built from the PHP manual page date_interval_format() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.