THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

JavaScript getUTCDay() Method

Date Object Reference JavaScript Date Object

Example

Return the day of the week, according to universal time:

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

The result of n will be:

Try it Yourself »

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.

The UTC methods calculate their date assuming that the date object is of local time and date.

Tip: The Universal Coordinated Time (UTC) is the time set by the World Time Standard.

Note: UTC time is the same as GMT time.


Browser Support

Method
getUTCDay() Yes Yes Yes Yes Yes

Syntax

Date.getUTCDay()

Parameters

None

Technical Details

Return Value: A Number, from 0 to 6, representing the day of the week
JavaScript Version: 1.3

Examples

More Examples

Example

Return the name of the weekday (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()];

The result of n will be:

Try it Yourself »

Date Object Reference JavaScript Date Object