--- title: Date.prototype.setMinutes() slug: Web/JavaScript/Reference/Global_Objects/Date/setMinutes translation_of: Web/JavaScript/Reference/Global_Objects/Date/setMinutes ---
setMinutes() 方法根据本地时间为一个日期对象设置分钟数。
dateObj.setMinutes(minutesValue[, secondsValue[, msValue]])
dateObj.setMinutes(minutesValue)
minutesValuesecondsValuesecondsValue 参数,则必须同时指定 minutesValue 参数。msValuemsValue 参数,则必须同时指定 minutesValue 和secondsValue 参数。如果没有指定 secondsValue 和 msValue 参数,就会使用 {{jsxref("Date.getSeconds", "getSeconds()")}} 和 {{jsxref("Date.getMilliseconds", "getmilliseconds()")}} 方法的返回值。
如果有一个指定的参数超出了合理范围,setMinutes 会相应地更新日期对象中的时间信息。例如,为 secondsValue 指定 100,分钟数将会加 1,而秒数会为 40。
setMinutes方法var theBigDay = new Date(); theBigDay.setMinutes(45);
| 规范版本 | 规范状态 | 注解 |
|---|---|---|
| ECMAScript 1st Edition. Implemented in JavaScript 1.0 | Standard | Initial definition. |
| {{SpecName('ES5.1', '#sec-15.9.5.32', 'Date.prototype.setMinutes')}} | {{Spec2('ES5.1')}} | |
| {{SpecName('ES6', '#sec-date.prototype.setminutes', 'Date.prototype.setMinutes')}} | {{Spec2('ES6')}} |
{{Compat("javascript.builtins.Date.setMinutes")}}