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 July 2015.

getMilliseconds() メソッドは、地方時に基づき、指定された日時の「ミリ秒」を返します。

試してみましょう

const moonLanding = new Date("July 20, 69 00:20:18");
moonLanding.setMilliseconds(123);

console.log(moonLanding.getMilliseconds());
// Expected output: 123

構文

js
getMilliseconds()

返値

地方時に基づき、指定された日時の「ミリ秒」を表す 0 から 999 までの間の数値。

getMilliseconds() の使用

次の例は、現在時刻のミリ秒部を変数 milliseconds に代入します。

js
const today = new Date();
const milliseconds = today.getMilliseconds();

仕様書

Specification
ECMAScript® 2025 Language Specification
# sec-date.prototype.getmilliseconds

ブラウザーの互換性

BCD tables only load in the browser

関連情報