Date.prototype.getUTCDate()
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.
getUTCDate()
メソッドは、協定世界時に基づき、指定された日時の月内の日(1 ~ 31)を返します。
試してみましょう
const date1 = new Date("August 19, 1975 23:15:30 GMT+11:00");
const date2 = new Date("August 19, 1975 23:15:30 GMT-11:00");
console.log(date1.getUTCDate());
// Expected output: 19
console.log(date2.getUTCDate());
// Expected output: 20
構文
js
getUTCDate()
返値
数字です。
Date
オブジェクトが有効な日時を表している場合は、指定された日時の曜日を表す 1 から 31 までの整数値(世界標準時による)。
それ以外の場合は、 Date
オブジェクトが有効な日時を表していない場合は NaN
を返します。
例
getUTCDate() の使用
次の例は、現在日時の「日」の部分を変数 dayOfMonth
に代入します。
js
const today = new Date();
const dayOfMonth = today.getUTCDate();
仕様書
Specification |
---|
ECMAScript® 2025 Language Specification # sec-date.prototype.getutcdate |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
getUTCDate |
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.