how to calculate days between two dates in php

Solutions on MaxInterview for how to calculate days between two dates in php by the best coders in the world

showing results for - "how to calculate days between two dates in php"
Ornella
03 Jan 2018
1$startDate = new DateTime("2019-10-27");
2$endDate = new DateTime("2020-04-11");
3
4$difference = $endDate->diff($startDate);
5echo $difference->format("%a");
Paula
20 Jul 2016
1<?php
2function dateDifference($start_date, $end_date)
3{
4    // calulating the difference in timestamps 
5    $diff = strtotime($start_date) - strtotime($end_date);
6     
7    // 1 day = 24 hours 
8    // 24 * 60 * 60 = 86400 seconds
9    return ceil(abs($diff / 86400));
10}
11 
12// start date 
13$start_date = "2016-01-02";
14 
15// end date 
16$end_date = "2016-01-21";
17 
18// call dateDifference() function to find the number of days between two dates
19$dateDiff = dateDifference($start_date, $end_date);
20 
21echo "Difference between two dates: " . $dateDiff . " Days ";
22?> 
queries leading to this page
php list all days between two datesmatch 2 dates and return days phpphp number of days between two datesdifference between 2 dates in phpno of days between dates phpget days from two dates phpget days left from 2 dates phpcalculate days between 2 dates phpphp months between two datesphp get all dates between two dateshow to calculate differencing time into two variables in phphow to calculate days between two dates in phpcalculate 2 different time phpcalculate days between two dates in phphow to get months between two dates in phphow to 3 year duration calculate in phpget datediffrence in phpfind difference between two dates php in daysphp get difference in days between two dates if positive valuephp calculate days between datesget number days between 2 date phpdiffernt 2 days in phpget days name between two dates phpdays between dates in phpphp days difference between 2 datesphp calculate average interavl between multiple datescount difference between two dates in phpcalculate days between dates phpcount days between two dates in php using sqlphp find days difference from start date to end datephp date difference between two datesphp get diff number of daysget total days from two dates phpcalculate no of days between two dates in phpphp calc days between datesget number of minutes between two dates phphow to get total days from two dates using phpphp 2 datetime differce inh 3am 3ascount days between dates in phpdifference between number of days in phpphp count month between two datesdate difference phphow to get 2 dates to days phpphp get days between two datesphp duration between two datesnumber of days between two dates phpprint all the days between two dates phptwo difference date count day phpphp total days between two datescalculate the difference between two dates using phpphp number days between two datesget day between two dates phpphp get difference between two dates in daysfind years between two dates phpdays difference between two dates in phphow to take difference of two dates in php and convert in intcount days between two dates phpget quantity of days between two dates phpphp difference between two dates in days phpget difference between two dates in phpcalculate days difference in phpfind days difference in phphow many days between two dates phpdate difference in days phpsubtract two dates to get days php how to get the difference between two dates in phpphp weeks between 2 datesget difference in year phpcount day between two dates phpdays calculation between two dates in phpnumber of days betwen two days phpphp get period between datesdifference bewteen two date php and obtain yearsget days difference between current date and time in phphow to count days between two dates in phpcheck if a date is more than 3 days phpget days between two dates gap phpphp count days between two dateshow to get total days between two dates in phpphp date between daysphp get seconds between 2 timeshow do i calculate number of days between two dates in phpphp get the diference between two datesecho date difference htmlphp date differencediffernce between string dates phpphp get number of days between two timestampsphp show difference between dates in daysdays difference between two dates in php 7 4how to get no of days in between 2 days in phpcount month between two dates phpdiff phpphp difference between 2 dates in daysphp difference between two dates in daysdatediff phphow to calulate between two dates in phpdifference between two dates php in daysdiff in days between dates phpdays between dates phpobtain the umber of date of difference between two date phplist days between two dates phpfind days between two dates phpsubtract two dates and get number of days phpdate difference 7 days phpphp get number of days between 2 datesdate difference in phpphp get dates between two dates2 dates between days in phpphp get no of days between two datescount days betwen two dates phpdifference between dates in days phpdifference between two dates in phpcalculate days between two dates in php 7 4get weeks between two dates phpphp daytime diff number of daystotal number of days between two dates in phpcalculate number of days between two dates phphow to find number of days between two dates in phpdatedifference phpcalculate days between phphow to get days difference in phpphp 2 date times to get difference in dayshow much day between 2 dates phpget difference of a date in days phpphp get number of days between 2 dates strtotimeget no of days between two dates phpphp diff timespandiffrenet between 2 date in phpphp two same date weeks countget all dates between two dates phphow to get number of days between two dates in php compleat programget the days between two dates into an array phpphp two dates difference daysculculate date phphow to calculate how many weeks between two dates in phpphp date difference in daysget difference between two dates in days phpphp date range between two datestwo date difference in phpget time between dates plus and minus in phpcalculate number of days between dates phpphp difference between 2 dates in year month day from dateget the number of days between two dates in phphow to calculate days between two dates in php