Friday, October 2, 2015

[PHP] 兩個日期相差多少天 (使用 DateTime::diff)

PHP官網

$datetime1 = new DateTime('2009-10-11');
$datetime2 = new DateTime('2009-10-13');
$interval = $datetime1->diff($datetime2);
echo $interval->format('%R%a days');

No comments:

Post a Comment