The getUTCDay() method returns an integer number corresponding to the day of the week for the given date, according to universal time: 0 for Sunday to 6 for Saturday.
Example
HTML Online Editor
<!DOCTYPE html>
<html>
<body>
<p>Click the button to display the UTC day of the current date.</p>
<buttononclick="myFunction()">Display UTC Day</button>
<pid="point"></p>
<script>
functionmyFunction() {
vard=newDate();
varn=d.getUTCDay();
document.getElementById("point").innerHTML=n;
}
</script>
</body>
</html>
In the following example, we will get the UTC Day of the weekday from a specific date.
Example
HTML Online Editor
<!DOCTYPE html>
<html>
<body>
<p>Click the button to display the UTC Day of the given date.</p>
<buttononclick="myFunction()">Display UTC Day</button>
<pid="point"></p>
<script>
functionmyFunction() {
vard=newDate("May 19, 1995 02:30:25");
varn=d.getUTCDay();
document.getElementById("point").innerHTML=n;
}
</script>
</body>
</html>