Latest web development tutorials

JavaScript getUTCDay () method

Date Object Reference JavaScript Date Object

Examples

Returns the day of the week is a number:

var d = new Date();
var n = d.getUTCDay();

n output:


try it"


Definition and Usage

getUTCDay () method returns a number that represents the day of the week according to the world.

Note: Sunday is 0, Monday is 1 , and so on.

Coordinated Universal Time (UTC) in seconds when the atomic length based on the time metering system as close as possible in a time when the world.

Tip: Coordinated Universal Time, also known as the unified world time, Universal Time, Coordinated Universal Time, abbreviated UTC (Universal Coordinated Time).

Note: UTC time is the GMT (Greenwich Mean) time.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support getUTCDay () method


grammar

Date.getUTCDay()

return value

类型 描述
Number 该值是 0(星期天) ~ 6(星期六) 中的一个值。

technical details

JavaScript version: 1.3


More examples

Examples

Now, I will create an array, so that the above example can output the name of weeks, 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()];

n output:


try it"


Date Object Reference JavaScript Date Object