Calculate the Difference Between Two Dates Using PHP
$firstDate = "2019-01-01"; $secondDate = "2020-03-04"; $dateDifference = abs(strtotime($secondDate) - strtotime($firstDate)); $years = floor($dateDifference / (365 * 60 * 60 * 24)); $months = floor(($dateDifference - $years * 365 * 60 * 60 * 24) / (30 * 60 * 60 * 24)); $days = floor(($dateDifference - $years * 365 * 60 * 60 * 24 - $months * 30 * 60 * 60 *24) / (60 * 60 * 24)); echo $years." year, ".$months." months and ".$days." days"; //output: 1 year, 2 months and 3 days