JavaScript setUTCMonth

JavaScript setUTCMonth function is a Date Function, which is used to set Month of a specified date as per the universal time. The syntax of the JavaScript setUTCMonth function is:

 Date.setUTCMonth(Month_Number)

Here, Month Number should be between 0 and 11. Where 0 = January, and 11 = December.

JavaScript setUTCMonth Function Example

We use the setUTCMonth fucntion to set the current date month to 5 (June) as per the universal time.

<!DOCTYPE html>
<html>
<head>
    <title> JavaScript Set UTC Month Functions </title>
</head>
<body>
    <h1> JavaScript setUTCMonth Function Example </h1>
<script>
  var dt = Date();  
  document.write("Date and Time : " + dt + "<br/>");

  dt.setUTCMonth(5);
  document.write("After setUTCMonth() : " + dt);
</script>
</body>
</html>
JavaScript setUTCMonth Example

Date and Time: Thu Nov 08 2018 12:28:57 GMT+0530 (Indian Standard Time)
After setUTCMonth(): Fri jun 08 2018 12:28:57 GMT+0530 (Indian Standard Time)

JavaScript set UTC Month Example 2

In this JavaScript set UTC Month function example, we set the custom date month to 11 (December) according to universal time.

<!DOCTYPE html>
<html>
<head>
    <title> JavaScript Set UTC Month Functions </title>
</head>
<body>
    <h1> JavaScript setUTCMonth Function Example </h1>
<script>
  var dt = Date("May 1, 2016 10:11:19");
  document.write("Date and Time : " + dt + "<br/>");

  dt.setUTCMonth(11);
  document.write("After setUTCMonth() : " + dt);
</script>
</body>
</html>
JavaScript setUTCMonth Function 1