DateTime::diff method
<?php
$startDate = new DateTime('2020-11-08');
$endDate = new DateTime('2020-11-10');
$diff = $endDate->diff($startDate);
$numberOfDays = $diff->days;
echo $numberOfDays;
<?php
$startDate = new DateTime('2020-11-08');
$endDate = new DateTime('2020-11-10');
$diff = $endDate->diff($startDate);
$numberOfDays = $diff->days;
echo $numberOfDays;
Leave a Comment
Cancel reply