JavaScript Date setMinutes() method
The JavaScript date setMinutes() method is used to set the minutes for a specified date on the basis of local time.
Syntax
The setMinutes() method is represented by the following syntax:
Parameter
minValue – It represents an integer value between 0 and 59, specifying the minutes. If the provided minute value is greater than 59, the setMinutes() method increments the hour value accordingly.
secValue ? It is optional. It represents an integer value between 0 and 59, specifying the seconds. If the provided second value is greater than 59, the setMinutes() method increments the minute value accordingly
msValue ? It is optional. It represents an integer value between 0 and 999, specifying the milliseconds. If the provided millisecond value is greater than 999, the setMinutes() method increments the second value accordingly.
JavaScript Date setMinutes() method example
Here, we will understand setMinutes() method through various examples.
Example 1
Let’s see an example to print current and updated minute value.
Output:
Current Minute : 57 Updated Minute : 32
Example 2
Let’s see an example to update the minute value of the given time.
Output:
Updated Minute : 32
Example 3
In this example, we will specify the seconds value (greater than 59) with the minutes.
Output:
Updated Minute : 23