Moment.js: Date between dates

后端 未结 8 1497
庸人自扰
庸人自扰 2020-11-27 11:18

I\'m trying to detect with Moment.js if a given date is between two dates. Since version 2.0.0, Tim added isBefore() and isAfter() for date compari

8条回答
  •  离开以前
    2020-11-27 11:58

    I do believe that

    if (startDate <= date && date <= endDate) {
      alert("Yay");
    } else {
      alert("Nay! :("); 
    }
    

    works too...

提交回复
热议问题