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

JavaScript setUTCMinutes() Method

JavaScript setUTCMinutes() Method

JavaScript setUTCMinutes() method is used to set the minutes of a given input date object according to the universal time (UTC) that is the time set by the World Time Standard.

Syntax:
Date.setUTCMinutes(min, sec, millisec)

Parameter Values

Parameter Description
min This is a required parameter. It defines an integer representing the minutes.
sec This is an optional parameter. It defines an integer representing the seconds.
millisec This is an optional parameter. It defines an integer representing the milliseconds.

Browser Support

Method Chrome Edge Firefox Safari Opera
setUTCMinutes() Yes Yes Yes Yes Yes
Here is an example of JavaScript setUTCMinutes method:
<html>
<body>
<p>Click the button to see the Output.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() 
{
  var d = new Date();
  d.setUTCMinutes(25);
  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();
  d.setUTCMinutes(d.getUTCMinutes() - 60);
  document.getElementById("demo1").innerHTML = d;
}
</script>
</body>
</html>
Output:

Click the button to see the Output.


No Sidebar ads