此函数返回两个日期范围重叠的天数:
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多少。
在性能方面,最好的方法是什么?