PHP的两个日期范围中有多少个工作日和周末重叠?

时间:2015-06-30 22:06:40

标签: php date datetime compare overlap

此函数返回两个日期范围重叠的天数:

function datesOverlap($start_one,$end_one,$start_two,$end_two) {

   if($start_one <= $end_two && $end_one >= $start_two) { //If the dates overlap
        return min($end_one,$end_two)->diff(max($start_two,$start_one))->days + 1; //return how many days overlap
   }

   return 0; //Return 0 if there is no overlap
}

我想知道的具体是WEEKDAYS多少次以及WEEKENDS多少。

在性能方面,最好的方法是什么?

0 个答案:

没有答案