PHP date_interval_format () / DateInterval :: format () function
PHP Date / Time Reference Manual
The interval between two dates, and then format the interval:
Examples
<? php
$ date1 = date_create ( "2013-01-01" );
$ date2 = date_create ( "2013-02-10" );
$ diff = date_diff ($ date1, $ date2);
//% A total output of between two dates Days
echo $ diff -> format ( "total number of days for the date interval:% a day.");
?>
$ date1 = date_create ( "2013-01-01" );
$ date2 = date_create ( "2013-02-10" );
$ diff = date_diff ($ date1, $ date2);
//% A total output of between two dates Days
echo $ diff -> format ( "total number of days for the date interval:% a day.");
?>
Running instance »
Definition and Usage
date_interval_format () function is DateInterval :: format () alias.
DateInterval :: format () function is used to format time intervals.
grammar
DateInterval::format( format);
参数 | 描述 |
---|---|
format | 必需。规定格式。 format 参数字符串可以使用下列的字符:
注意:每个格式字符串必须带一个 % 符作为前缀! |
technical details
return value: | Returns formatted time interval. |
---|---|
PHP version: | 5.3+ |
PHP Date / Time Reference Manual