Date.prototype.getMilliseconds()
Date 实例的 getMilliseconds() 方法根据当地时间返回该日期的毫秒数。
¥The getMilliseconds() method of Date instances returns the milliseconds for this date according to local time.
Try it
语法
参数
返回值
示例
使用 getMilliseconds()
¥Using getMilliseconds()
milliseconds 变量的值为 0,基于 Date 对象 xmas95 的值,该值未指定毫秒部分,因此默认为 0。
¥The milliseconds variable has value 0, based on the value of the Date object xmas95, which doesn't specify the milliseconds component, so it defaults to 0.
js
const xmas95 = new Date("1995-12-25T23:15:30");
const milliseconds = xmas95.getMilliseconds();
console.log(milliseconds); // 0
规范
| Specification |
|---|
| ECMAScript Language Specification # sec-date.prototype.getmilliseconds |
浏览器兼容性
BCD tables only load in the browser