The below function is used to calculate number of working days in a month. Function Calling: $no_days= rns_countDays ($row['date'],array(0, 6)); Function: function rns_countDays($date, $ignore) { //echo countDays(array(0, 6), start_date, end_date); $count = 0; $ndays=0; $now=date("Y-m-d"); $month=date("m",strtotime($date)); $year=date("y",strtotime($date)); if($month==date("m") && $year==date('y')) { //Date diff month start date to current date $from_date = new DateTime($year.'-'.$month.'-01'); $to_date = new DateTime($now); $days_diff=$from_date->diff($to_date); //echo $days_diff->d; $ndays=$days_diff->format("%a"); ...