It appears Intl.DateTimeFormat() only accepts "narrow", "short", "long" as the weekday option. I would like it to return as a number. i.e. Sunday = 0, Monday = 1 and so on. If I'm correct in reading "numerical" is not an option, what would be an easy way to return the value weekday as a number?
const day = new Intl.DateTimeFormat('en-US', {
timeZone: America/New_York,
weekday: 'long',
});
const weekdayNumber = ["0", "1", "2", "3", "4", "5", "6"];
const dayNumber = weekdayNumber[day.format(now)];
console.log('Weekday: ' + dayNumber); // returns error
Easy way would be
Date.prototype.getDay():If by all means you want to use something to "look it up", this would be one approach to get the weekday as a number: