calculcate number of days betwen 2 dates php code example
Example 1: Get the number of days between two dates in PHP
$startDate = new DateTime("2019-10-27");
$endDate = new DateTime("2020-04-11");
$difference = $endDate->diff($startDate);
echo $difference->format("%a");
Example 2: how to calculate days difference between two dates in php
use DateTime;
$startDate = new DateTime($request->start_date);
$endDate = new DateTime($request->end_date);
$daysDifference = ($startDate->diff($endDate)->days);