此 setUTCSeconds()
方法为一个依据国际通用时间的特定日期设置秒数。
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
dateObj.setUTCSeconds(secondsValue[, msValue])
secondsValue
msValue
一个毫秒数,表示从国际通用时间1970年00:00:00到设置的时间值之间的时间跨度。
如果你没有设置msValue参数的值, 那么返回的值来自getUTCMilliseconds()
方法。
如果你指定的值超出了范围, setUTCSeconds()
因此会更新Date
对象中date的相关信息 . 举个例子, 如果你设置secondsValue为100, Date
对象中的分钟数会增加1, 并且秒数会变成40.
setUTCSeconds()
var theBigDay = new Date();
theBigDay.setUTCSeconds(20);
说明 | 状态 | 备注 |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard | 初始化设定. 从 JavaScript 1.3继承. |
ECMAScript 5.1 (ECMA-262) Date.prototype.setUTCSeconds |
Standard | |
ECMAScript 2015 (6th Edition, ECMA-262) Date.prototype.setUTCSeconds |
Standard | |
ECMAScript Latest Draft (ECMA-262) Date.prototype.setUTCSeconds |
Draft |
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | Server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
setUTCSeconds | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |