Calculating the Number of Days Between Two Dates in PHP


Find the difference between two dates.

Source Code

$date1 = new DateTime("2020-01-01");
$date2 = new DateTime("2020-01-31");
$diff = $date1->diff($date2);
echo $diff->days . " days";
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments