Date.prototype.setUTCDate()
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.
setUTCDate()
メソッドは、指定された Date
インスタンスの「日」を UTC 時刻に基づいて変更します。
ローカル時間に基づいて指定された Date
インスタンスの「日」を変更するには、 setDate()
メソッドを使用してください。
試してみましょう
const event = new Date("August 19, 1975 23:15:30 GMT-3:00");
console.log(event.getUTCDate());
// Expected output: 20
event.setUTCDate(19);
console.log(event.getUTCDate());
// Expected output: 19
構文
js
setUTCDate(dayValue)
引数
dayValue
-
任意。「日」を表す 1 から 31 までの間の整数値。
返値
協定世界時 (UTC) 1970 年 1 月 1 日 00:00:00 から更新された日時までの間のミリ秒単位の数値。
解説
例
setUTCDate() の使用
js
const theBigDay = new Date();
theBigDay.setUTCDate(20);
仕様書
Specification |
---|
ECMAScript® 2025 Language Specification # sec-date.prototype.setutcdate |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
setUTCDate |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.