Getting the date of next Monday

前端 未结 9 496
臣服心动
臣服心动 2020-12-02 23:06

How can I get the next Monday in JavaScript? I can\'t find anything of this in the internet and I have also tried a lot of codes and understanding of this but I can\'t reall

9条回答
  •  隐瞒了意图╮
    2020-12-02 23:31

    Please try this

    d = new Date(d);
    var day = d.getDay(),
    diff = d.getDate() - day + (day == 0 ? -6:1);
    alert(new Date(d.setDate(diff)));
    

提交回复
热议问题