Date.prototype.setUTCMilliseconds()

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.

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

試してみましょう

const date1 = new Date("2018-01-24T12:38:29.069Z");

console.log(date1.getUTCMilliseconds());
// Expected output: 69

date1.setUTCMilliseconds(420);

console.log(date1.getUTCMilliseconds());
// Expected output: 420

構文

js
setUTCMilliseconds(millisecondsValue)

引数

millisecondsValue

「ミリ秒」を表す 0 から 999 までの間の整数値。

返値

協定世界時 (UTC) 1970 年 1 月 1 日 00:00:00 から更新された日時までの間のミリ秒単位の数値。

解説

指定した値が期待される日付の範囲外の場合、それに応じて setUTCMilliseconds()Date オブジェクトの日付情報の更新を試みます。例えば、millisecondsValue に 1100 を指定した場合、Date オブジェクトに格納された秒の数値に 1 が加算され、ミリ秒に 100 が使用されます。

setUTCMilliseconds() の使用

js
const theBigDay = new Date();
theBigDay.setUTCMilliseconds(500);

仕様書

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

ブラウザーの互換性

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
setUTCMilliseconds

Legend

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

Full support
Full support

関連情報