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

JavaScript setUTCDate() Method

JavaScript setUTCDate() Method

JavaScript setUTCDate() method is used to set the given input day of the month according to the universal time (UTC). UTC is the Universal Coordinated Time set by the World Time Standard.

Syntax:
Date.setUTCDate(day)

Parameter Values

Parameter Description
day This is a required parameter. If defines an integer representing the day of a month.

Browser Support

Method Chrome Edge Firefox Safari Opera
setUTCDate() Yes Yes Yes Yes Yes
Here is an example of JavaScript setUTCDate() method:
<html>
<body>
<p>Click the button to see the OPutput.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() 
{
  var d = new Date();
  d.setUTCDate(14);
  document.getElementById("demo").innerHTML = d;
}
</script>
</body>
</html>
Output:

Click the button to see the Output.

Example 2:
<html>
<body>
<p>Click the button to see the Output.</p>
<button onclick="myFunction1()">Try it</button>
<p id="demo1"></p>
<script>
function myFunction1() 
{
  var d = new Date("March 10, 2020 15:15:00");
  d.setUTCDate(08);
  document.getElementById("demo1").innerHTML=d;
}
</script>
</body>
</html>
Output:

Click the button to see the Output.


No Sidebar ads