setUTCMilliseconds()
方法会根据世界时来设置指定时间的毫秒数。
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.setUTCMilliseconds(millisecondsValue)
参数
-
millisecondsValue
- 0 - 999 之间的数值,代表毫秒数。
返回值
返回更新后的时间距 1970 年 1 月 1 日 00:00:00 (UTC) 的毫秒数。
描述
如果传递的参数超出了指定的范围,setUTCMilliseconds() 方法会相应地尝试更新储存在
Date
的秒数会加 1,然后使用 100 来作为毫秒数。
示例
使用 setUTCMilliseconds() 方法
var theBigDay = new Date(); theBigDay.setUTCMilliseconds(500);
规范
规范版本 | 规范状态 | 注解 |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard | 初始定义。于 JavaScript 1.3 实现。 |
ECMAScript 5.1 (ECMA-262) Date.prototype.setUTCMilliseconds |
Standard | |
ECMAScript 2015 (6th Edition, ECMA-262) Date.prototype.setUTCMilliseconds |
Standard | |
ECMAScript Latest Draft (ECMA-262) Date.prototype.setUTCMilliseconds |
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.
Update compatibility data on GitHub
Desktop | Mobile | Server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
setUTCMilliseconds |
Chrome Full support 1 | Edge Full support 12 | Firefox Full support 1 | IE Full support 4 | Opera Full support Yes | Safari Full support Yes | WebView Android Full support 1 | Chrome Android Full support 18 | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support 1.0 | nodejs Full support Yes |
Legend
- Full support
- Full support