PHP date_interval_format()Functions
PHP Date/Time Reference Manual
Calculate the interval between two dates, then format the time interval:
Examples
<?php
$date1=date_create("2013-01-01");
$date2=date_create("2013-02-10");
$diff=date_diff($date1,$date2);
// %a outputs the total number of days between two dates
echo $diff->format("The total number of days between the dates is: %a days.");
?>
$date1=date_create("2013-01-01");
$date2=date_create("2013-02-10");
$diff=date_diff($date1,$date2);
// %a outputs the total number of days between two dates
echo $diff->format("The total number of days between the dates is: %a days.");
?>
Run Example »
Definition and Usage
The date_interval_format() function is an alias of DateInterval::format().
The DateInterval::format() function is used to format a time interval.
Syntax
DateInterval::format(format);
| Parameter | Description |
|---|---|
| format | Required. Specifies the format.formatThe parameter string can use the following characters:
Note:Each format string must be prefixed with a % sign! |
Technical Details
| Return Value: | Returns the formatted time interval. |
|---|---|
| PHP Version: | 5.3+ |
PHP Date/Time Reference Manual Other Extensions