如何在JavaScript中添加月份到日期? [重複] - How to add months to a date in JavaScript? [duplicate]

問題:

This question already has an answer here: 這個問題在這裏已有答案:

I want to add months to a date in JavaScript. 我想在JavaScript中添加幾個月的日期。

For example: I am inserting date 06/01/2011 (format mm/dd/yyyy ) and now I want to add 8 months to this date. 例如:我正在插入日期06/01/2011 (格式mm/dd/yyyy ),現在我想在這個日期添加8個月。 I want the result to be 02/01/2012 . 我希望結果是02/01/2012

So when adding months, the year may also increase. 因此,當添加月份時,年份也可能會增加。


解決方案:

參考一: https://en.stackoom.com/question/NgXK
參考二: https://stackoom.com/question/NgXK
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章