--- title: Date.prototype.setMilliseconds() slug: Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds translation_of: Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds ---
setMilliseconds() 方法会根据本地时间设置一个日期对象的豪秒数。
dateObj.setMilliseconds(millisecondsValue)
millisecondsValue如果指定的数字超出了合理范围,则日期对象的时间信息会被相应地更新。例如,如果指定了 1005,则秒数加 1,豪秒数为 5。
setMillisecondsvar theBigDay = new Date(); theBigDay.setMilliseconds(100);
| 规范版本 | 规范状态 | 注解 |
|---|---|---|
| ECMAScript 1st Edition. Implemented in JavaScript 1.3 | Standard | Initial definition. |
| {{SpecName('ES5.1', '#sec-15.9.5.28', 'Date.prototype.setMilliseconds')}} | {{Spec2('ES5.1')}} | |
| {{SpecName('ES6', '#sec-date.prototype.setmilliseconds', 'Date.prototype.setMilliseconds')}} | {{Spec2('ES6')}} |
{{Compat("javascript.builtins.Date.setMilliseconds")}}