Getting the Difference Between Two Dates in PHP


Calculate the difference between two dates in days.

Source Code

$startDate = new DateTime("2023-01-01");
$endDate = new DateTime("2023-01-31");
$interval = $startDate->diff($endDate);
echo "Difference : " . $interval->days . " days";
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments