Get the day of the week, according to universal time:
let day = d.getUTCDay();
More "Try it Yourself" examples below.
Definition and Usage
The getUTCDay() method returns the day of the week (from 0 to 6) for the specified date, according to universal time.
Note: Sunday is 0, Monday is 1, and so on.
UTC time (Coordinated Universal Time) is the time set by the World Time Standard.
UTC time is the same as GMT time (Greenwich Mean Time).
All getUTC methods assume that the date object is of local time and date.
It is fully supported in all browsers:
|Return Value:||A Number, from 0 to 6, representing the day of the week|
Get the name of the weekday (not just a number):
const weekday = new Array();
weekday = "Sunday";
weekday = "Monday";
weekday = "Tuesday";
weekday = "Wednesday";
weekday = "Thursday";
weekday = "Friday";
weekday = "Saturday";
let day = weekday[d.getUTCDay()];