The setMinutes() method sets the minutes of a date object.
The setMinutes() method sets the minutes of a date object.
This method can also be used to set the seconds and milliseconds.
Date.setMinutes(min,sec,millisec)
Parameter | Require | Description |
---|---|---|
min | Required. | An integer representing the minutes. |
sec | Optional. | An integer representing the seconds |
millisec | Optional. | An integer representing the milliseconds |
For the minute value, the expected values are 0-59, but other values are allowed:
For the second value, the expected values are 0-59, but other values are allowed:
For the millisec value, the expected values are 0-999, but other values are allowed:
A Number, representing the number of milliseconds between the date object and midnight January 1 1970
Set the minutes to 17:
//display the date after changing the minutes. var d = new Date(); d.setMinutes(17);/*from ww w . j ava2 s.com*/ console.log(d); //Set the date time to be 90 minutes ago: d.setMinutes(d.getMinutes() - 90); console.log(d);