JavaScript getUTCDay() Method
Example
Return a number representing the day of the week:
var d = new Date();
var n = d.getUTCDay();
n Output result:
Try it »
Definition and Usage
The getUTCDay() method returns a number representing the day of the week based on universal time.
Note: Sunday is 0, Monday is 1, and so on.
Coordinated Universal Time (UTC) is a time measurement system based on the atomic second, designed to stay as close as possible to universal time.
**Tip:** Coordinated Universal Time, also known as Universal Time, World Standard Time, or International Coordinated Time, abbreviated as UTC (Universal Coordinated Time).
**Note:** UTC time is the same as GMT (Greenwich) time.
Browser support





All major browsers support the getUTCDay() method.
Syntax
Date
.getUTCDay()
Return Value
| Type | Description |
|---|---|
| Number | The value is a number between 0 (Sunday) and 6 (Saturday). |
Technical Details
| JavaScript version: | 1.3 |
|---|
More examples
Example
Now I will create an array so that the example above can output the name of the day of the week instead of just a number:
var d=new Date();
var weekday=new Array();
weekday[0]="Sunday";
weekday[1]="Monday";
weekday[2]="Tuesday";
weekday[3]="Wednesday";
weekday[4]="Thursday";
weekday[5]="Friday";
weekday[6]="Saturday";
var n = weekday[d.getUTCDay()];
n Output result:
Try it »
JavaScript Date object