JavaScript getUTCDay Function

JavaScript getUTCDay function is one of the Date Functions, which returns the day number of a given date according to universal time. Day Number starts at 0 and ends at 6, where 0 as of Sunday, six as Saturday. The syntax of the getUTCDay function is:

 Date.getUTCDay()

getUTCDay Example

Here, we use getUTCDay to return the day number from the current date and time.

<!DOCTYPE html>
<html>
<head>
    <title> JS </title>
</head>
<body>
    <h1> Example </h1>
<script>
  var dt = Date();  
  document.write("Date and Time : " + dt);
  document.write("UTC Day : " + dt.getUTCDay());
</script>
</body>
</html>
Example

Date and Time: Mon Nov 05 2018 10:37:44 GMT+0530 (Indian Standard Time)
UTC Day : 1

Example

In this JavaScript get UTC Day example, we are displaying the day number from the custom date.

<!DOCTYPE html>
<html>
<head>
    <title> JavaScript Get UTC Day Function </title>
</head>
<body>
    <h1> JavaScriptgetUTCDayFunctionExample </h1>
<script>
  var dt = Date("April 1, 2016 10:14:22");
  document.write("Date and Time : " + dt);
  document.write("UTC Day using getUTCDay : " + dt.getUTCDay());
</script>
</body>
</html>
getUTCDay Example