For calculating the day difference between two dates using Php. we already have a function for this in Php which can give us the date difference, the Function Named as date_diff().
Basic Syntax:
date_diff(datetime1, datetime2, absolute)
In PHP date_diff() function first, two parameters are required and the third one is optional.which accepts the boolean value and by default, it's 'False'.
Let's take example to see the difference between dates:
<?php
$startdate = date_create("2020-03-24");
$enddate = date_create("2020-04-22");
$difference = date_diff($date1, $date2);
echo $difference->format("%R%a days");
?>
Output:
+29 days