setUTCDate()
メソッドは、協定世界時に基づき、指定された日付の「日」を設定します。
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
構文
dateObj.setUTCDate(dayValue)
引数
dayValue
- 任意。「日」を表す 1 から 31 までの間の整数値。
返値
協定世界時 (UTC) 1970 年 1 月 1 日 00:00:00 から更新された日時までの間のミリ秒単位の数値。
解説
指定した値が期待される日付の範囲外の場合、それに応じて setUTCDate()
が Date
オブジェクトの日付情報の更新を試みます。例えば、dayValue
に 40 を指定し、Date
に格納された「月」が 6 月の場合、「日」は 10 に変更され、「月」が繰り上がって 7 月になります。
例
setUTCDate() の使用
var theBigDay = new Date();
theBigDay.setUTCDate(20);
仕様書
ブラウザーの互換性
BCD tables only load in the browser