How to loop through months in Javascript

后端 未结 3 475
温柔的废话
温柔的废话 2021-01-12 15:02

I\'m trying to generate a list of string dates in months (i.e. [\"Oct 2014\", \"Nov 2014\",... \"Jan 2015\" ]) using the code here:

var resultList = [];
v         


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-12 15:14

    Use setMonth() instead of setDate() to sets the month of the date variable.

    date.setMonth(date.getMonth() + 1);
    

提交回复
热议问题