How can I calculate the difference between two dates in PHP? Example code: - Biz Tech

How can I calculate the difference between two dates in PHP? Example code:

Listen
$date1 = "2022-03-05";
$date2 = "2022-03-10";

$diff = abs(strtotime($date2) - strtotime($date1));
$days = floor($diff / (60 * 60 * 24));

echo "The difference between the two dates is " . $days . " days";