Header Code

Find number of weekdays (Mon, Tues etc)  between  two dates 08Dec, 2011

function workingDays( $fromDate, $interval ) {
$date_array = explode(‘-‘, $fromDate );
$day = $date_array[0];
$month = $date_array[1];
$year = $date_array[2];
$working_date = array();

for ( $i = 1; $i <= $interval; $i++ ) {
$working_date[] = date(“l”, mktime(0, 0, 0,$month,$day +(int)$i,$year));


return $working_date;


$getDays = workingDays(’30-11-2011’, 30 );
str_replace(array(‘Friday’),array(‘Friday’) ,$getDays, $dupweekDays); // trick to check the occurrence of week days
echo $dupweekDays;

Explanation of the above code:

$getWorkingDays = workingDays(’30-11-2011′, 30 );

W call the workingDays function it accept two prams a) the start date 2) the number of days between to dates

This function will return the name of weekdays i.e Monday, Tuesday,Wednesday , Thursday , Friday , Saturday , Sunday

——————————————————————————————————————————————————————————————————————-Below is str_replace(array(‘Friday’) , array(‘Friday’) ,$getDays, $dupweekDays); // trick to check the occurrence of week days
echo $dupweekDays;

the login to find the repeating days so we we need to find number of Mondays then we need to replace the first and second parameter of str_replace function with array(‘Monday’)

The $dupweekDays will the variable having the count of repeating Mondays

Posted by: Deepak Saini / In: PHP