number of week days between two dates in php

Solutions on MaxInterview for number of week days between two dates in php by the best coders in the world

showing results for - "number of week days between two dates in php"
Jesús
03 Jul 2019
1$startDate = new DateTime("2019-10-27");
2$endDate = new DateTime("2020-04-11");
3
4$difference = $endDate->diff($startDate);
5echo $difference->format("%a");
Juno
03 Sep 2018
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?> 
Nele
03 Aug 2020
1You are given two string (dd-mm-yyyy) representing two date, 
2you have to find number of all weekdays present in between given dates.
3  
4function number_of_days($days, $start, $end) {
5	$start = strtotime($start); $end = strtotime($end);
6	$w = array(date('w', $start), date('w', $end));
7	$x = floor(($end-$start)/604800);
8	$sum = 0;
9	for ($day = 0;$day < 7;++$day) {
10		if ($days & pow(2, $day)) {
11			$sum += $x + ($w[0] > $w[1]?$w[0] <= $day || $day <= $w[1] : $w[0] <= $day && $day <= $w[1]);
12		}
13	}
14	return $sum;
15}
16
17function getWeeklyDayNumbers($startDate, $endDate) {
18	$weekdays = array('monday' => 0, 'tuesday' => 0, 'wednesday' => 0, 'thursday' => 0, 'friday' => 0, 'saturday' => 0, 'sunday' => 0);
19	$weekdays['monday'] += number_of_days(0x02, $startDate, $endDate); // MONDAY
20	$weekdays['tuesday'] += number_of_days(0x04, $startDate, $endDate); // TUESDAY
21	$weekdays['wednesday'] += number_of_days(0x08, $startDate, $endDate); // WEDNESDAY
22	$weekdays['thursday'] += number_of_days(0x10, $startDate, $endDate); // THURSDAY
23	$weekdays['friday'] += number_of_days(0x20, $startDate, $endDate); // FRIDAY
24	$weekdays['saturday'] += number_of_days(0x40, $startDate, $endDate); // SATURDAY
25	$weekdays['sunday'] += number_of_days(0x01, $startDate, $endDate); // SUNDAY
26	return $weekdays;
27}
28
29$weekdays = getWeeklyDayNumbers('01-01-2021', '31-01-2021');
30print_r($weekdays);exit;
31
Fátima
05 Oct 2016
1function numWeeks($dateOne, $dateTwo){
2    //Create a DateTime object for the first date.
3    $firstDate = new DateTime($dateOne);
4    //Create a DateTime object for the second date.
5    $secondDate = new DateTime($dateTwo);
6    //Get the difference between the two dates in days.
7    $differenceInDays = $firstDate->diff($secondDate)->days;
8    //Divide the days by 7
9    $differenceInWeeks = $differenceInDays / 7;
10    //Round down with floor and return the difference in weeks.
11    return floor($differenceInWeeks);
12}
13
14$numOfWeek = numWeeks('2021-01-21', '2021-01-28');
queries leading to this page
count month between two dates phpcalculate number of days between two dates except for sunday in phpfinding the number of months between two dates in phptwo weeks ago phpphp calculate date difference in weeksphp year range between two datesphp date difference in daysphp get 2 days before datecount day between two dates phpphp calc date deltaget day between two dates phpphp date between two datesphp count days weeks and monthget number of weeks between two dates phphow to check if date is between two dates phpfinding time difference in php in daysdate difference between two dates in phpdifference in days of two dates in phphow to check date between two dates in phpget no of time day appear between two dates phphow to get the difference from 2 datephp get all week dayshow to calculate years months and days between two dates in phpdifrence of two dates in phpphp difference between two date for timerget all days of week phpdifference 2 weeks phpdays week phpphp 2 date times to get difference in daysphp date diff in daysget 2 weeks after date in phphow to get two days time in phpphp get diff number of dayshow to get the difference between two dates in phpcalculate days between two dates in phpdatetime diff in days two dates with sign phpget two weeks dates phpphp diff datephp get all months between 2 dateshow to calculate differencing time into two variables with date format in php in laravelphp difference between dates in daysphp results between two datesphp program to find number of week from total days number of months between two dates phpphp subtract two datesphp list of days of weekcaculartor date time of month in phpphp get difference in days between two dates if positive valuehow to get days name between two dates in phpget number of days between two dates in phpmonths between two dates phpcount the weeknds between 2 dates phpphp get days of week in date rangephp date difference now and specified datecalculate time between dates phpphp date time calculation 2b1php get days of a weekconvert number of week into days in phpphp difference between two dates in daysphp get days between two datesphp count how many weeks between datescalculate days between dates phpphp get interval between two datesphp count working days between two dateshow to get number of days between two current datre and a given date in php sqlnumber of days between a date and current date in phpget days and hours and menunt from data phpnumber of days between two dates in phpfind difference between two dates phpfinding days between two dates in phpcalculate date phpphp count days of week in a monthphp every 4 days in week php days between dateshow many days between two dates phpphp check days in between dateshow to get number of days between two dates in php compleat program find year month dayhow to calculate days dufference between teo dates by using one datebis current date in phplaravel calculate the end date date 2b elapsed timecalculate number of days in phpcompare two dates differenct phpdatediff in php to find difference between today and any datephp number of days between datesfind years between two dates phpphp calculate days between datesphp get all 2 weeks future dates how to count days difference in phpphp calculate number of months between two dateswrite code in php to calculate the total number of days between two dates 3fget days from two dates phphwo to check days differnce between twio dates phpdifference between current date and given date in php in daysdatetime two days phpphp days bettwen datesget amount of days between two dates phpphp get date differencefinding date difference in phpfind difference of hours in type html in php codephp how many months weeks and days between 2 datesdays difference from month 26 date only phpphp date range between two dateslist days between two dates phpphp difference between two dates in years 2c months and dayslaravel algorithm for calculate a duration of datehow much day between 2 dates phpnum of days between two days phptwo date difference in phpcalculate days using dates phpdate diff dayscheck if a date is more than 3 days phpdiff between start and end date time phphow to get the difference in days between two dates in phphow to check difference between 2 date 28 29 in phpget days left from 2 dates phpcalculate percentage between two dates phpget days between two dates phphow to 3 year duration calculate in phphow many months between two date phpfind number of days between two dates phpphp get years between two date rangecalculate days and time in phpdifference between dates in days phpdate difference in days phpphp difference seconds between two datedays difference with number phpphp logic for check current time between two datesphp months between two datesphp get week interval between two datesi need the difference between 2 dates in php get the days between two dates into an array phpphp weeks between two dateshow to get difference between two dates phpday plus and minus between dates in phpphp number of days between two dates excluding weekendsphp 7 date differentsget days difference between current date and time in phpphp days difference between 2 datesget the number of days between two dates in phpcheck date fall between two days in phpphp difference between 2 dates in daysecho date difference htmlphp two weeks count from date to currentfind days with name between two dates in phpcount days between two dates phget dates between two dates in phphow to count days difference in php to today 27s datephp get difference between two dates in daystwo date time difference strtotime php calculate number of nights between two dates phpphp print all days between dateshow to know my date between two dates in php count no of days between two dates in php2nd day of the week in php datetimephp subtract two dates fing statusfind number of months between two dates phpecho date differenceget time between dates plus and minus in phpget total days from two dates phpphp get all dates between two datesdate diff days phpphp daytime diff number of daysphp difference between two dates in years months and daysphp date get days of weekget difference in dates in php as daysconvert difference in years between two dates phpphp get all years between two datesphp echo all days between two datescalculate days between one date and now phphow to calculate days in between dates using phpdays between dates in phpget difference of date in php get daysno of days in diff of two dates phphow to differentiate two date for one weekget dates between two dates phpcalculate days between phpcheck current week is in two dates phpcount difference between two dates in phpdays between two dates in phpcalculate years between two dates in phpphp get date and time between two datesdifference in days between two dates phpsubtract two dates and get number of days phpphp get 2 weeks future datecount the no of days between two date time in phpget date to week days name in phpdate difference in days in phpcalculate days between two dates in php 7 4dates between two phphow to get total days from two dates using phpnumber of months between two dates in phphow to get number of days between two dates in phpwrite a php script to get time difference in days and years 2c months 2c days 2c hours 2c minutes 2c seconds between two dates note 3a use datetime class php day difference between two datescalculate difference between two dates in phpget all days between two dates phpphp days of weekdate calculate formula in phpcheck current week exists in two dates phpget the different dates between two dates phpphp get seconds between 2 timesget number days between 2 date phpphp weeks between 2 datesdays calculation between two dates in phpdays count between two dates phpphp get date between two dateshow to find number of days between two dates in php2 date compare php hours secondsphp get dates between two datesdiff in days two dates phpget start end end date of years in array date diffcount days between dates in phpphp range between two dates since the same dayget datediffrence in phpdifference between dates phphow to calculate difference between two dates in phpfind number of weekends between two dates phpfind number of days lies between two date in phpget date time 2 days than now phpusing days to calculate weeks in phpdays difference by number phpdatediff php format ifget total number of days from date diff in phpnumbers of day between two dates in phpday count between two dates in phpdifference between two dates in php in daysdatedifference phpcount days between two dates phpdifference in dates phpculculate date phpcalculate total days between two dates in phpcalculate the difference in weeks between two dates phpdattime diff more than 1 month in laraveldiffernt 2 days in phphow to get the number of days in between 2 dates in phpcheck if date is less than two weeks from current date phpphp every 5 days in weekcalculate days difference between two dates in phpphp number of days between two datescalculcate number of days betwen 2 dates phpphp get every monday between 2 datesnumber of dates between two dates phpget dates from now two weeks phphow to find the difference between time in phpfind number of working days between two dates phpget all the weeks between two weeks phphow to get months between two dates in phphow to get number of days between two dates in php complete program find year month dayphp date diffget weeks months and years between two dates laravelstrtotime two dates time difference php php calculate difference between two datesphp difference between two dates in days phpphp difference between 2 dates in year month day from dateget num of dates from two dates phpget days duration phphow to get total days between two dates in phpget difference between datehow to get date difference in phphow to get days between two dates in phpdate after 10 weeks from given date in phpphp date difference in months and daysphp days between two date2 date day hourse seconds compare phpphp date diff a h icalculate no of days between two dates phpcount days between two dates in php using sqlphp get all days between two dates in arraylist of months between two dates in phphow to check difference between 2 data 28 29 in phpdifference between two date variable in phphow to get each day between two dates in phptwo time difference dateformat phpfunction to calculate the duration between two dates in php and consider the date rangelist of date between two dates phpsubtract two dates to get days php check number of weeks from total day in phpfind the difference between two datetimes phpno of years between two dates in phpphp date range 2 weeks agophp date format between 2 datesphp dateinterval minutes between two dateshow to find the between two dates in phpget days week in phpfunction to calculate days between dates in phpphp get number of days between 2 dates strtotimecalculate number of days months and years between two dates phphow can we know the number of days between two given dates using php 3f how to get days difference in phphow to get 2 date betwwen in phpcalculate years between two dates phpnumber of days between two dates phpphp get months between two datesfunction between two dates phpphp number of day in weeksfinding the number of days between two dates variable phpno of days between two dates in phphow to get 2 dates to days phpdifference between dates in phphow to get number of days between two dates in php compleat programget number of minutes between two dates phphow to get no of days in between 2 days in php2 dates between days in phpphp two dates difference daysdifference bewteen two date php and obtain yearsget difference of 365 days from two dates in phphow to calculate days difference between two dates in phpphp total days between two dateshow to get the difference in years of two dates in phpcheck html time diffrenece phpget the number of months between two dates phpget all days of week in phpcalculate number of days between two dates phpdiff date php find daysget date after 2 days phpday difference between two datetime in phpget all dates between two dates phpphp count month between two datesget number of months between two dates phpphp calculate age between two datescalculate post end date phpcalculate date difference php in daysdate difference phpphp days between to timephp check how many days between two datescalculate difference between dates phpfind number of days between two dates except for sunday phpphp days between 2 datesphp duration between two datesdays difference between two dates in php 7 4php date diff weeksget number of weeks months two dates phpget years between two dates phpdays of the week in phpget two days before date of current date in phpget difrance between two dates in phpcalculate the difference between multiple date ranges phpphp get working days between two dates arrayphp date two digit weekget all dates between two dates in phpfind difference between two dates php in dayscount number of days between two days phpphp get no of days between two datesphp date diff weeks and monthdatetime diff php weekscalculate difference between two dates phphow to subtract two datetime in phpcreate date and difference in phpdifference in days phpdisplay list of years between two dates phphow to get the date of 2 days befor current month in phphow to subtract two dates in phpdate diff 14 daysdifference between 2 dates in phpcalculate months between two dates phpphp calculate date after daysdifference between two dates php dayscalculate days between 2 dates in php php tdays between two datescheck time between two times in all weeks phpfind days difference in phpdiff of two date php php how many weeks in date rangetotal number of days between two dates in phpdiff date weeks phpdifference between two dates phpphp find date between two datesfinding time difference of one day phpphp get number of days between 2 datesphp get array days between two datesget no of days between two dates phpget date difference php less than 1how to calulate between two dates in phpphp 2 dates get days namescalculate the difference between two dates using phpphp number days between two datesphp date between daysphp get difference between two datesget two weeks ago date in phpcalculate 2 different time phpphp difference between datesphp get dates in period between two datesdiff two date phpget months 2cdays years from two given date in phptwo difference date count day phpphp days between two datesdate to date range calculator phpphp get 7 between datescalculate number of days between dates phpdiff between date php in daysget day between two date in phphow many number of 15th between two dates phpno of days between dates phpphp day is between datesget total days between two dates phpcheck two dates and get day phpget days between two dates gap phpobtain the umber of date of difference between two date phpphp diff timespannumber of days from two dates phpcalculate no of months between two dates phpphp5 4 get total sec difference 2 datetimeprint all the days between two dates phpphp get difference between 2 datescalculate age difference between two dates in phphow to get all year between two dates in phpdate difference 7 days phptwo date diffrent year phpphp list week days for a period of 1 monthdiff 28 29 function phpnumber of week days between two dates in phpcount days between two dates in phpphp calculate number of days between two datesphp count days between two datesget number day of two dates phphow can we know the number of days between two given dates using phphow to find months between two dates in phpphp show difference between dates in dayscount the days between two dates in phpdays between dates phpget the difference between two dates in days phpphp get days of week numberphp get the diference between two datescalculate date difference in php in daysdays on each week on a months phpdays difference between two dates phpfind days between two dates phphow to convert the php string to date object and find the difference of 2 datesget value between two dates phphow to find out how many days are between two dates phpdiff in days between dates phphow to calculate differencing time into two variables in phpphp date two dates minutes hoursmatch 2 dates and return days phphow to calculate number of days in between two dates in phpwrite a program to find no of days between two dates in php 3fget days difference between two dates phpphp 2 datetime differce inh 3am 3asphp list all days between two datescalculate difference between two calculated time in phpdifference between two dates in phpcalculate days difference in phpphp current date 2 daysno of dates between two dates phphow to calculate two date difference in phpphp date time fid weekend days between two datesphp get day difference between two datesget exact difference dates phpphp calculate average interavl between multiple datesphp get number of months between two datesphp get date difference in daysnumber of years from timestemp phpget elemenets between two dates phpday difference between two dates in phpphp calculate days between two datetime variablecalculate days between 2 dates phpcalculate difference in two dates phpget dift to dates phpfind date within weeks or month phphow to get number of days between two current datre and a given date in phpget difference between two timestamps database in minutes phphow to calculate the time between two dates in phphow to calculate how many weeks between two dates in phpget diff in date from todaydate add 1 week php0101 3a0909 3a0000 format difference in phpdate difference in php in daysnumber of day in week phpweek count between two dates phphow do i calculate number of days between two dates in phpget number of days between two dates phpphp how many weeks between datesget days between 2 date phpphp time difference in daysget difference between two dates in phphow to find number of days difference between two dates in phpdiffernce between string dates phpcurren date 2b2 days in phpphp how to get all 2 weeksget dates between 2 dates phpget years betwen two years phphow to find days in between dates in phpget quantity of days between two dates phpphp number of months between two datesphp add a day to a date interval using diff to calculate days betweenhow to check weekend date between two dates in phpdate difference calculator in phpdiffrenet between 2 date in phpget two date day difference phpphp calc days between datesget weeks between two dates phphow to find saturday date between two dates phpphp date differencecount days betwen two dates phpphp get years between two datescount days between dates phpget difference of a date in days phpphp 2 dates get days names between datesget days name between two dates phpphp list all days this weekphp calculate interavl between datesnumber of days betwen two days phpdays by week phpget difference between two dates phpphp date difference between two datescalculate number of days between two dates without weekends phpdate diff php days hoursphp find days difference from start date to end datecalculate from date to date phpcalculate days between two dates phpfind year month day in php from secondshow to get months 2cdays years from two given date in phpbetween two dates in phpget 6 days of week php2 date difference phpget the difference in days between two dates in phpdifference between two dates php in daysphp get working days between two datescalculate no of weeks between two dates in phpdate difference in phpduration between two datesphphow to check if a date is between two dates phphow to calculate days between two dates in phpphp get days from two datesphp count weekdays between two datesphp difference in days between two dateshow to know which month is exist beetween two date in phpphp date two digit week numberif date more than 3 days then phpphp get period between datesdate difference php in daysphp sql compare time between two datesphp calculate days between two datesfind date between two dates phpcount days between two dates in mysql using phpphp calculate weeks between two dateswrite a php script to calculate a number of days between two datesdiff phpget week days from date in phphow to take difference of two dates in php and convert in intget difference between two dates in days phpdiference between dates php dayphp query count days between two datescalculate no of days between two dates in phphow to check two dates fall between another two days in phpphp 2 days from nowdate diff php 7php two same date weeks countget time difference between two dates phpcheck if date fall betwen two days in phpphp dates between two datesdatediff phpphp calculate time between two utils datesphp generate days between two datesphp calculate months between two datesphp get list of dates between two datesprint days by week number php days difference between two dates in phpphp find days between two datesget difference in year phphow to find number of sundays between two dates in phpcompare dates within 30 days phpcount the days between two dates phpdiff 1 month phphow to count days between two dates in phpphp get number of days between two datesfind date withinn weeks phpfinding day difference between two times phpdiff with two date current date time and database current date tiemphp check difference between two dates in mget day difference between two dates phpget 2 days before date in phpphp 3aget number of day between two datesphp calculate date difference in daysphp get number of nights between two datescalculate difference between two dates in php in year monthphp day count between two datesphp no of days between two datesphp get days between datesnumber of week days between two dates in php