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

JavaScript setMinutes() Method

JavaScript setMinutes() Method

The setMinutes() is an inbuilt method in JavaScript which is used to set the minutes of a date object on the basis of local time. It accepts an integer representing the Minutes.

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

Parameter Values

Parameter Description
min It is Required and represents an integer value between 0 and 59 (specifying the minutes). This method increments the hour value, if the provided minute value is greater than 59.
sec It is Optional and represents an integer value between 0 and 59 (specifying the seconds). This method increments the minutes value, if the provided seconds value is greater than 59.
millisec It is Optional and represents an integer value between 0 and 999 (specifying the milliseconds). This method increments the seconds value, if the provided milliseconds value is greater than 999.

Browser Support

Method Chrome Edge Firefox Safari Opera
setMinutes() Yes Yes Yes Yes Yes
Here is an Example of setMinutes() Method:
<html>
<body>
<button onclick="mySetMin()">click me</button>
<p id="setMin"></p>
<script>
function mySetMin()
{
  var d = new Date();
  d.setMinutes(25);
  document.getElementById("setMin").innerHTML = d;
}
</script>
</body>
</html>
Output:

Example 2:
<html>
<body>
<script>
var SetMinutes=new Date();	
document.writeln("Current Minute : "+SetMinutes.getMinutes()+"<br>");
SetMinutes.setMinutes(28);
document.writeln("Updated Minute : "+SetMinutes.getMinutes());
</script>
</body>
</html>
Output:

No Sidebar ads