JavaScript function to add X months to a date

后端 未结 19 2066
星月不相逢
星月不相逢 2020-11-22 02:44

I’m looking for the easiest, cleanest way to add X months to a JavaScript date.

I’d rather not handle the rolling over of the year or have to write my own function.<

相关标签:
19条回答
  • 2020-11-22 03:27
    var a=new Date();
    a.setDate(a.getDate()+5);
    

    As above stated method, you can add month to Date function.

    0 讨论(0)
提交回复
热议问题