JavaScript getUTCDay()Method
Examples
Returns a number representing the day of the week:
var d = new Date();
var n = d.getUTCDay();
var n = d.getUTCDay();
nOutput:
Try it yourself »
Definition and Usage
The getUTCDay() method returns a number representing the day of the week according to universal time.
Note: Sunday is 0, Monday is 1, and so on.
Coordinated Universal Time (UTC) is a time measurement system based on the length of the atomic second, and is kept as close as possible to Universal Time.
Tip:Coordinated Universal Time, also known as World Unified Time, World Standard Time, 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 one of 0 (Sunday) to 6 (Saturday). |
Technical Details
| JavaScript Version: | 1.3 |
|---|
More Examples
Example
Now, I will create an array so that the above example can output the name of the day of the week, not 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()];
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()];
nOutput:
Try it yourself »
Other Extensions
JavaScript Date Object