JavaScript function to add X months to a date

后端 未结 19 2092
星月不相逢
星月不相逢 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:18

    Sometimes useful create date by one operator like in BIRT parameters

    I made 1 month back with:

    new Date(new Date().setMonth(new Date().getMonth()-1));   
    

提交回复
热议问题