Date.prototype.getUTCMilliseconds()

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.

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

試してみましょう

const exampleDate = new Date("2018-01-02T03:04:05.678Z"); // 2 January 2018, 03:04:05.678 (UTC)

console.log(exampleDate.getUTCMilliseconds());
// Expected output: 678

構文

js
getUTCMilliseconds()

返値

数値です。 もし Date オブジェクトが有効な日時を表している場合には、指定された Date オブジェクトの世界時によるミリ秒単位を表す 0 から 999 までの整数値です。 それ以外の場合は、Date オブジェクトが有効な日時を表していなければ NaN が返されます。

Unix 元期の時刻と混同しないでください。 1970/01/01 からの経過ミリ秒を取得するには、 getTime() メソッドを使用してください。

getUTCMilliseconds() の使用

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

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

仕様書

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

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
getUTCMilliseconds

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報