# 求两个时间段是否与另两个时间段有重合

0

A1(20161001) ----- B1(20161101)

A2(20160201) ----- B2(20161101)

A1(20161001) ----- B1(20171001)

A2(20161101) ----- B2(20161220)

20161001是2016年10月01日

ahhg | 初学一级 | 园豆：3

0

`max(a1,a2)<=min(b1,b2)`

Daniel Cai | 专家六级 |园豆：10424 | 2016-12-01 10:35

ahhg | 园豆：3 (初学一级) | 2016-12-01 14:44

0

var time1Ticks = Convert.ToDateTime("2016-10-01").Ticks;
var time2Ticks = Convert.ToDateTime("2016-11-01").Ticks;

var time3Ticks = Convert.ToDateTime("2016-02-01").Ticks;
var time4Ticks = Convert.ToDateTime("2016-11-01").Ticks;

GDOUJKZZ | 园豆：315 (菜鸟二级) | 2016-12-01 08:55

```var new_start_time = Date.parse(new Date('2016-11-19 10:11:00'));
var new_end_time = Date.parse(new Date('2016-11-19 12:20:20'));

var start_time = Date.parse(new Date('2016-11-18 20:00:20'));
var end_time = Date.parse(new Date('2016-11-19 09:57:40'));
//new的时间段不在另一个时间段区间中
console.log(new_start_time > end_time,new_end_time > start_time);//true,true 不能满足

new_start_time = Date.parse(new Date('2016-11-19 10:11:00'));
new_end_time = Date.parse(new Date('2016-11-19 12:20:20'));

start_time = Date.parse(new Date('2016-11-18 20:00:20'));
end_time = Date.parse(new Date('2016-11-19 19:57:40'));

//new时间段在另一个时间段中
console.log(start_time <= new_start_time && new_start_time <= end_time);//true 可以满足

new_start_time = Date.parse(new Date('2016-11-19 10:11:00'));
new_end_time = Date.parse(new Date('2016-11-20 08:20:20'));

start_time = Date.parse(new Date('2016-11-19 11:00:20'));
end_time = Date.parse(new Date('2016-11-19 23:57:40'));
//new时间段在另一个时间段中
console.log(start_time <= new_start_time && new_start_time <= end_time);//false 不能满足
console.log(start_time <= new_end_time && new_end_time <= end_time);//false 不能满足```

0

guodaxia | 园豆：87 (初学一级) | 2016-12-01 09:10
0

```//新时间段
var new_start_time = Date.parse(new Date('2016-11-19 10:11:00'));
var new_end_time = Date.parse(new Date('2016-11-19 12:20:20'));

var start_time = Date.parse(new Date('2016-11-18 20:00:20'));
var end_time = Date.parse(new Date('2016-11-19 09:57:40'));

new_start_time > end_time; //true
new_end_time > start_time; //true

@ahhg: (new_start_time>start_time&&new_start_time<end_time)

|| (new_end_time>start_time&&new_end_time<end_time)

0

您需要登录以后才能回答，未注册用户请先注册