Date.prototype.getMilliseconds()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
getMilliseconds() 方法根据本地时间,返回一个指定的日期对象的毫秒数。
尝试一下
const moonLanding = new Date("July 20, 69 00:20:18"); moonLanding.setMilliseconds(123); console.log(moonLanding.getMilliseconds()); // Expected output: 123 语法
js
getMilliseconds() 参数
无
描述
getMilliseconds() 方法返回一个 0 到 999 的整数。
示例
>示例:使用getMilliseconds方法
下例中,将当前时间的毫秒数赋值给变量 ms。
js
var ms; Today = new Date(); ms = Today.getMilliseconds(); 规范
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-date.prototype.getmilliseconds> |