Спасибо за помощь, но я получил ответ.
function getWorkingHours($ini_str,$end_str){
//config
$ini_time = [8,0]; //start working (hr, min)
$end_time = [17,0]; //end working (hr, min)
//date objects
$ini = date_create($ini_str);
$ini_wk = date_time_set(date_create($ini_str),$ini_time[0],$ini_time[1]);
$end = date_create($end_str);
$end_wk = date_time_set(date_create($end_str),$end_time[0],$end_time[1]);
//days
$workdays_arr = getWorkDays($ini,$end);
$workdays_count = count($workdays_arr);
$workday_seconds = (($end_time[0] * 60 + $end_time[1]) - ($ini_time[0] * 60 + $ini_time[1])) * 60;
//get time difference
$ini_seconds = 0;
$end_seconds = 0;
if(in_array($ini->format('Y-m-d'),$workdays_arr)) $ini_seconds = $ini->format('U') - $ini_wk->format('U');
if(in_array($end->format('Y-m-d'),$workdays_arr)) $end_seconds = $end_wk->format('U') - $end->format('U');
$seconds_dif = $ini_seconds > 0 ? $ini_seconds : 0;
if($end_seconds > 0) $seconds_dif += $end_seconds;
//final calculations
$working_seconds = ($workdays_count * $workday_seconds) - $seconds_dif;
$working_seconds_format = gmdate("H:i:s", $working_seconds);
return $working_seconds_format; //return hrs
}
function getWorkDays($ini,$end){
//config
$skipdays = [5,6]; //friday:5; saturday:6; sunday:0
$skipdates = []; //eg: ['2016-10-10'];
//vars
$current = clone $ini;
$current_disp = $current->format('Y-m-d');
$end_disp = $end->format('Y-m-d');
$days_arr = [];
//days range
while($current_disp <= $end_disp){
if(!in_array($current->format('w'),$skipdays) && !in_array($current_disp,$skipdates)){
$days_arr[] = $current_disp;
}
$current->add(new DateInterval('P1D')); //adds one day
$current_disp = $current->format('Y-m-d');
}
return $days_arr;
}
echo getWorkingHours('2019-10-10 20:00:00', '2019-10-13 19:59:30'); //thir-sun:
Ссылка: Расчет рабочего времени между двумя датами