Use DateTime() and DateInterval() Objects for PHP 5.3 and Above and Calculate the Difference Between Two Dates Using PHP
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