JavaScript setMinutes() Method
Example
Set the minutes field to 17:
var d = new Date();
d.setMinutes(17);
d Output result:
Try it »
Definition and Usage
The setMinutes() method is used to set the minutes field of a specified time.
This method can also be used to set the seconds and milliseconds.
Browser support





All major browsers support the setMinutes() method.
Syntax
Date
.setMinutes(
min
,
sec
,
millisec
)
Parameter value
| Parameters | Description |
|---|---|
| min | Required. A value representing the minutes,
between 0 and 59, in local time (the same applies below): |
between 0 and 59. This parameter was not supported before EMCAScript standardization:
- -1 is the last second of the previous minute
- 60 is the first second of the next minute.
, between 0 and 999. This parameter was not supported before EMCAScript standardization:
- -1 is the last millisecond of the previous second
- 1000 is the first millisecond of the next second.
Return Value
| Type | Description |
|---|---|
| Number | Returns the number of milliseconds from January 1, 1970 to the adjusted date. Before ECMAScript standardization, this method returned nothing. |
Technical Details
| JavaScript version: | 1.0 |
|---|
More examples
Example
Set the date to 90 minutes earlier:
var d = new Date();
d.setMinutes(d.getMinutes()-90);
d Output result:
Try it »
JavaScript Date object