我有一个数组,其中包含一组开始/结束日期对象(包括时间)
IE
results["records"] =
[0] -[startDate,endDate]
[1] -[startDate, endDate]
我还有另外两个日期对象在本地存储为 JS 变量。如何检查这些变量,即 startDateObj && endDateObj 是否与数组中的任何记录重叠,我的意思是与任何开始日期或结束日期之间的任何时间交叉,包括任何开始日期或结束日期。
先感谢您
下面的初步尝试
$(results['records']).each(function() {
console.log('end:' + this[1])
console.log('start:' + this[0])
if(startDateObj < this[1].end && endDateObj > this[0].start) {
alert('this overlaps')
}
});
编辑:下面添加的答案祝你有美好的一天!