Calculate Number of Weeks Between Two Dates using PHP

DateTime::diff method

<?php

$startDate = new DateTime('2022-06-01');
$endDate = new DateTime('2022-06-10');

$diff = $endDate->diff($startDate);
$numberOfWeeks = floor($diff->days / 7);

echo $numberOfWeeks;

Leave a Comment

Cancel reply

Your email address will not be published.