I want to print something like this (a 7-day calendar) but with the ability to start from any date I want.
Monday, 1 January 2011
Tuesday, 2 January 2011
Wed
If you need next 7 weekdays starting from today
const isWeekday = (date) => {
return date.weekday()!==0 && date.weekday()!==6
}
const weekdays=[];
let numberOfDaysRequired = 7
let addDaysBy = 1
moment.locale('en')
while(weekdays.length < numberOfDaysRequired)
{
const d = moment().add(addDaysBy, 'days')
if(isWeekday(d))
{
weekdays.push(d.format('ffffdd, Do MMMM YYYY'))
}
addDaysBy++;
}
console.log(weekdays)