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");
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");
php calculate weeks between two dates
function numWeeks($dateOne, $dateTwo){
//Create a DateTime object for the first date.
$firstDate = new DateTime($dateOne);
//Create a DateTime object for the second date.
$secondDate = new DateTime($dateTwo);
//Get the difference between the two dates in days.
$differenceInDays = $firstDate->diff($secondDate)->days;
//Divide the days by 7
$differenceInWeeks = $differenceInDays / 7;
//Round down with floor and return the difference in weeks.
return floor($differenceInWeeks);
}
$numOfWeek = numWeeks('2021-01-21', '2021-01-28');
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us