$datetime1 = new DateTime('2020-10-11 16:52:52');
$datetime2 = new DateTime('2020-10-13 16:52:52');
$interval = $datetime1->diff($datetime2);
echo $interval->format('%a days');
$interval = $datetime1->diff($datetime2);
$diffInSeconds = $interval->s;
$diffInMinutes = $interval->i;
$diffInHours = $interval->h;
$diffInDays = $interval->d;
$diffInMonths = $interval->m;
$diffInYears = $interval->y;
$earlier = new DateTime("2010-07-06");
$later = new DateTime("2010-07-09");
$pos_diff = $earlier->diff($later)->format("%r%a"); //3
$neg_diff = $later->diff($earlier)->format("%r%a"); //-3