共计 395 个字符,预计需要花费 1 分钟才能阅读完成。
面向对象风格:
<?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";
正文完