m
使用PHP计算两个日期之间相隔多少天
面向对象风格:
<?php
$january = new DateTime('2010-01-01');
$february = new DateTime('2010-02-01');
$interval = $february->diff($january);
// %a will output the total number of days.
echo $interval->format('%a total days')."\n";
过程式风格:
<?php
$january = date_create('2010-01-01');
$february = date_create('2010-02-01');
$interval = date_diff($january, $february);
// %a will output the total number of days.
echo $interval->format('%a total days')."\n";