主页
PHP
PHP date_interval_format() 函数
tryphp_func_date_interval_format
运行 ❯
×
更改方向
保存代码
更改主题
<?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 echo $diff->format("Total number of days: %a."); echo "
"; // %R outputs + beacause $date2 is after $date1 (a positive interval) echo $diff->format("Total number of days: %R%a."); echo "
"; // %d outputs the number of days that is not already covered by the month echo $diff->format("Month: %m, days: %d."); ?>