JavaScript Date getUTCDay()
Example
Get the weekday:
const d = new Date();
let day = d.getUTCDay();
Try it Yourself »
Get the name of the weekday (not just a number):
const weekday = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
const d = new Date();
let day = weekday[d.getUTCDay()];
Try it Yourself »
Definition and Usage
getUTCDay()
returns the day of the week (0 to 6) of a date.
getUTCDay()
returns the day of the week according to universal time.
Sunday = 0, Monday = 1, ... (See below):
Notes
UTC (Universal Time Coordinated) is the time set by the World Time Standard.
UTC time is the same as GMT time (Greenwich Mean Time).
All JavaScript getUTC methods assume that the date is of local time.
Syntax
Date.getUTCDay()
Parameters
NONE |
Return Value
Type | Description |
A number | The weekday of a date (0 to 6), according to UTC. |
Browser Support
getUTCDay()
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |