js日付を比較します.現在の時間は2つの日付の間にありますか?


var x = new Date('2015-05-25');
var y = new Date('2015-05-25');

// 1、        
if (x.getTime() == y.getTime()) {
  It'll be true;
}

// 2、        
// anything involving '=' should use the '+' prefix// it will then compare the dates' millisecond values
if (+x == +y) { It'll be true; } // 3、         if (x - y == 0) { It'll be true; }
 
//          

var beforeSpringDate, afterSpringDate;
  for (var i = 0; i < springFestivalDays.length; i++) {
    beforeSpringDate = new Date(springFestivalDays[i]);
    beforeSpringDate.setDate(beforeSpringDate.getDate() - 4);
    afterSpringDate = new Date(springFestivalDays[i]);
    afterSpringDate.setDate(afterSpringDate.getDate() + springFestivalPeriod - 1);
    if (time >= beforeSpringDate.getTime() && time <= afterSpringDate.getTime()) {
      result = true;
      break;
    }
  }