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.
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()]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With