JavaScript getUTCDay Function

JavaScript getUTCDay function is one of the Date Function, 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 JavaScript getUTCDay function is:

 Date.getUTCDay()

JavaScript getUTCDay Function Example

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

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

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

JavaScript get UTC Day Function Example

In this JavaScript getUTCDay function 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> JavaScript getUTCDay Function Example </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>
JavaScript getUTCDay Function 2