JavaScript getUTCDay

The JavaScript getUTCDay function returns the day of the week number of a given date according to Coordinated Universal Time (UTC). The day of the week number returned by the getUTCDay starts at 0 and ends at 6, where 0 = Sunday and 6 = Saturday.

The syntax of the getUTCDay function is:

 Date.getUTCDay()

Return Value: The getUTCDay() method does not accept any parameter value and returns an integer between 0 and 6. Here, the day of the week numbers start from 0 (Sunday) and end with 6 (Saturday).

JavaScript getUTCDay examples

In the following example, we use the getUTCDay() function to return the day of the week number from the current date and time. Here, the new Date() object returns the current date and time.

const dt = new Date();
let d = dt.getUTCDay()
console.log(d);
console.log(dt);
6 
Sat Jun 13 2026 10:22:08 GMT+0530 (India Standard Time)

Example 2: Get the day of the week from a custom date

In this JavaScript example, we use the Date() constructor to create a date from a string. Next, the getUTCDay method displays the day of the week number from the custom date.

const dt = new Date("April 1, 2016 10:14:22");
console.log(dt.getUTCDay());
console.log(dt.toString());
5 
Fri Apr 01 2016 10:14:22 GMT+0530 (India Standard Time)

Example 3: If you parse the string date without the day number (dd value), the Date() object constructs a date with the default value of the month start (1st). The JavaScript getUTCDay() function returns the day of the week number of 1st May 2026.

const dt = new Date("May 2026 10:14:22");
console.log(dt.getUTCDay());
console.log(dt.toString());
5 
Fri May 01 2026 10:14:22 GMT+0530 (India Standard Time)

Example 4: getUTCDay returns NaN

The getUTCDay() function works on a valid date field; when you use it on an invalid date, it returns NaN. In the example below, we use the date with the wrong month number 14, so it becomes an invalid date, and the getUTCDay() method returns NaN.

const dt = new Date("2026-14-02 10:14:22");
console.log(dt.getUTCDay());
console.log(dt.toString());
NaN 
Invalid Date

What is the difference between getUTCDate() and getUTCDay() in JavaScript?

  • The getUTCDate() returns the day of the month numbers between 1 and 31.
  • The getUTCDay() function returns the day of the week numbers from 0 (Sunday) to 6 (Saturday).

In the following example, we use both getUTCDate() and getUTCDay() to show the difference in results.

const dt = new Date();
console.log(dt);
console.log(dt.getUTCDate());
console.log(dt.getUTCDay());
Sat Jun 13 2026 11:14:50 GMT+0530 (India Standard Time) 
13 
6

JavaScript day of the week name

By default, the JavaScript getUTCDay() method returns the day of the week number between 0 and 6. However, we can use an array of week names from Sunday to Saturday and call it based on the index.

Please refer to the getDay() method to see an array example. In modern coding, we can follow the following approach to get the day of the week name.

const dt = new Date();
console.log(dt.getUTCDay());

const dayName = dt.toLocaleDateString("en-US",
{ weekday: "long", timeZone: "UTC"});
console.log(dayName);
6 
Saturday