javascript check date code example

Example: check date clash js

var date1 = [moment("2016-12-06 11:00"), moment("2016-12-06 12:00")];
var date2 = [moment("2016-12-06 10:00"), moment("2016-12-06 13:00")];

var range  = moment.range(date1);
var range2 = moment.range(date2);

// has overlapping
if(range.overlaps(range2)) {
    if((range2.contains(range, true) || range.contains(range2, true)) && !date1[0].isSame(date2[0]))
    alert("time range 1 is completely conflict with time range 2 and vice versa");
  else
    alert("time range 1 is partially conflict with time range 2 and vice versa");
}