Why setMinutes ?
JavaScript Date The setMinutes () method is a built-in function. This method returns the minutes of a specific date. This method can also be used to set seconds and milliseconds.
Syntax:
Date.setMinutes(minutesValue[, secondsValue[, msValue]])
- minutesValue: Represents the minutes. It takes values between 0 and 59.
- secondsValue: Represents the second. It takes values between 0 and 59.
- msValue: represents militias. Gets values from 0 to 999.
return:
- It returns the new date with updated minute which is set by setMinutes() function.
JavaScript setMinutes Examples
Example 1
Date With the setMinutes () method, we can change the minute value of a specific date.
var date = new Date('April 21, 1983 13:22:32:77');
console.log(date.getMinutes());
date.setMinutes(55);
console.log(date.getMinutes())
22
55
Example 2
Date With the setMinutes () method, we can change the current minute value.
var date = new Date();
console.log(date.getMinutes());
date.setMinutes(12);
console.log(date.getMinutes())
25
12
Example 3
var date = new Date();
console.log(date.getMinutes("April 21, 1983 22:47:55"));
date.setMinutes(55);
console.log(date.getMinutes())
console.log(date.getMilliseconds())
27
55
836
Browser Support
| Chrome | yes |
| Edge | yes |
| Firefox | 1 |
| Internet Explorer | yes |
| Opera | yes |
| Safari | yes |
| Android webview | yes |
| Chrome for Android | yes |
| Edge mobile | yes |
| Firefox for Android | 4 |
| Opera Android | yes |
Leave a comment