A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds below:

Date.prototype.setMilliseconds() - JavaScript | MDN

Date.prototype.setMilliseconds()

Baseline Widely available

setMilliseconds() は Date インスタンスのメソッドで、地方時に基づき、指定された日時の「ミリ秒」を設定します。

試してみましょう
const event = new Date("August 19, 1975 23:15:30");

console.log(event.getMilliseconds());
// 予想される結果: 0

event.setMilliseconds(456);

console.log(event.getMilliseconds());
// 予想される結果: 456
構文
setMilliseconds(millisecondsValue)
引数
millisecondsValue

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

返値

その場で Date オブジェクトを変更し、新しいタイムスタンプを返します。 millisecondsValue が NaN (または undefined など、 NaN に変換されるその他の値)の場合、日付は無効な日時に設定され、 NaN が返されます。

解説

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

例 setMilliseconds() の使用
const theBigDay = new Date();
theBigDay.setMilliseconds(100);
仕様書 ブラウザーの互換性 関連情報

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4