Home >>JavaScript Date Object Methods >JavaScript getUTCDay() Method

JavaScript getUTCDay() Method

JavaScript getUTCDay() Method

The getUTCDay() method is an inbuilt method in JavaScript which returns the day of the week (from 0 to 6) for the specified date on the basis of universal time. The value of the day starts with 0 that represent Sunday, Monday is 1, and so on.

Syntax:
Date.getUTCDay()

Browser Support

Method Chrome Edge Firefox Safari Opera
getUTCDay() Yes Yes Yes Yes Yes
Here is an Example of JavaScript getUTCDay() Method:
<html>
<body>
<button onclick="myUtcDay()">Click me</button>
<p id="UTCDAY"></p>
<script>
function myUtcDay() 
{
  var d = new Date();
  var day = d.getUTCDay();
  document.getElementById("UTCDAY").innerHTML = day;
}
</script>
</body>
</html>
Output:

Example 2:
<html>
<body>
<script>
var day1=new Date("January 5, 1997 21:25:20 GMT+12:00");
var day2=new Date("January 5, 1997 21:25:20 GMT-12:00");
document.writeln("Day value : "+day1.getUTCDay()+"<br>");
document.writeln("Day value : "+day2.getUTCDay());
</script>
</body>
</html>
Output:

No Sidebar ads