Date.prototype.setUTCSeconds()
此 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
- 一个在0到59之间的整数,表示秒数。
msValue
- 可选参数。一个0到999之间的数字,代表毫秒数。
返回值
一个毫秒数,表示从国际通用时间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 (ECMA-262) Date.prototype.setUTCSeconds |
Living Standard |
浏览器兼容性
BCD tables only load in the browser
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.