6
Here is my Code:
var listDate = [];
var startDate ='2017-02-01';
var endDate = '2017-02-10';
var dateMove = new Date(startDate);
var strDate = startDate;

while (strDate < endDate){
  var strDate = dateMove.toISOString().slice(0,10);
  listDate.push(strDate);
  dateMove.setDate(dateMove.getDate()+1);
};
console.log(listDate);

//["2017-02-01", "2017-02-02", "2017-02-03", "2017-02-04", "2017-02-05", "2017-02-06", "2017-02-07", "2017-02-08", "2017-02-09", "2017-02-10"]

it gives me the output with the month number like 2017-02-01, but i need the month name instead of month number. Pleae Help.

ABHISHEK S
  • 71
  • 1
  • 1
  • 8

1 Answers1

19

try this simple way : Create an array with all the month name's, and so use your index as key to find the good month.

var monthNames = ["January", "February", "March", "April", "May","June","July", "August", "September", "October", "November","December"];

var d = new Date();
console.log("The current month is " + monthNames[d.getMonth()]);
devseo
  • 1,182
  • 1
  • 13
  • 26
kumbhani bhavesh
  • 2,189
  • 1
  • 15
  • 26