📅  最后修改于: 2022-03-11 14:59:56.085000             🧑  作者: Mango
phpCopy$firstDate = new DateTime("2019-01-01");
$secondDate = new DateTime("2020-03-04");
$intvl = $firstDate->diff($secondDate);
echo $intvl->y . " year, " . $intvl->m." months and ".$intvl->d." day";
echo "\n";
// Total amount of days
echo $intvl->days . " days ";
//output: 1 year, 2 months and 1 day
// 428 days