Find next instance of a given weekday (ie. Monday) with moment.js

后端 未结 10 1101
旧巷少年郎
旧巷少年郎 2020-12-02 15:36

I want to get the date of the next Monday or Thursday (or today if it is Mon or Thurs). As Moment.js works within the bounds of a Sunday - Saturday, I\'m having to work out

10条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-02 15:55

    moment().day() will give you a number referring to the day_of_week.

    What's even better: moment().day(1 + 7) and moment().day(4 + 7) will give you next Monday, next Thursday respectively.

    See more: http://momentjs.com/docs/#/get-set/day/

提交回复
热议问题