JavaScript tutorial:
getUTCDay method

 

Applies to : Date Object

The getUTCDay method is use to get the day of the week value in a Date object using Universal Coordinated Time (UTC).

Syntax

objDate.getUTCDay()

Return

Returns the day of the week value in a Date object using UTC.

Example

To get the day of the week using local time, use the getDate method.

The value returned by the getUTCDay method is an integer between 0 and 6 representing the day of the week and corresponds to a day of the week as follows:

0 = Sunday
1 = Monday
2 = Tuesday
3 = Wednesday
4 = Thursday
5 = Friday
6 = Saturday

The following example illustrates the use of the getUTCDay method:

function DateDemo()
{
    var d, day, x, s = "Today is ";
    var x = new Array("Sunday", "Monday", "Tuesday");
    x = x.concat("Wednesday","Thursday", "Friday");
    x = x.concat("Saturday");
    d = new Date();
    day = d.getUTCDay();
    return(s += x[day]);
}

document.write(DateDemo());

To run the code above, paste it into JavaScript Editor, and click the Execute button

See also: Date Object Methods, getDay Method