how can i get the whole month in day namesof given month/year? like :
var year = \"2000\";
var month = \"7\"
... some code here that makes an array with nam
I know this is an old question, but today a question linked to this, and I'd like to point out one don't really need to do much things other than convert day (0-6)
to string (Sunday-Saturday)
function getDays(year, month) { //month: 1-based, as normal person
--month //change it to 0-based, as Date object
let dayname = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
let date = new Date(year, month)
let result = []
while(date.getMonth()==month){
result.push(`${date.getDate()}. ${dayname[date.getDay()]}`)
date.setDate(date.getDate()+1)
}
return result;
}
console.log(getDays(2019,12))