Date.prototype.setUTCMinutes()

Date 实例的 setUTCMinutes() 方法根据世界时间更改该日期的分钟。

¥The setUTCMinutes() method of Date instances changes the minutes for this date according to universal time.

Try it

语法

¥Syntax

js
setUTCMinutes(minutesValue)
setUTCMinutes(minutesValue, secondsValue)
setUTCMinutes(minutesValue, secondsValue, msValue)

参数

¥Parameters

minutesValue

0 到 59 之间的整数,表示分钟。

secondsValue Optional

0 到 59 之间的整数,表示秒。如果指定 secondsValue,则还必须指定 minutesValue

msValue Optional

0 到 999 之间的整数,表示毫秒。如果指定 msValue,则还必须指定 minutesValuesecondsValue

返回值

¥Return value

就地更改 Date 对象,并返回其新的 timestamp。如果参数为 NaN(或获取 coercedNaN 的其他值,例如 undefined),则日期设置为 失效日期,并返回 NaN

¥Changes the Date object in place, and returns its new timestamp. If a parameter is NaN (or other values that get coerced to NaN, such as undefined), the date is set to Invalid Date and NaN is returned.

描述

¥Description

如果不指定 secondsValuemsValue 参数,则使用从 getUTCSeconds()getUTCMilliseconds() 方法返回的值。

¥If you do not specify the secondsValue and msValue parameters, the values returned from getUTCSeconds() and getUTCMilliseconds() methods are used.

如果你指定的参数超出预期范围,setUTCMinutes() 会尝试相应地更新 Date 对象中的日期信息。例如,如果你使用 100 表示 secondsValue,则分钟将增加 1 (minutesValue + 1),秒将使用 40。

¥If a parameter you specify is outside of the expected range, setUTCMinutes() attempts to update the date information in the Date object accordingly. For example, if you use 100 for secondsValue, the minutes will be incremented by 1 (minutesValue + 1), and 40 will be used for seconds.

示例

¥Examples

使用 setUTCMinutes()

¥Using setUTCMinutes()

js
const theBigDay = new Date();
theBigDay.setUTCMinutes(43);

规范

Specification
ECMAScript Language Specification
# sec-date.prototype.setutcminutes

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看