Date.prototype.getUTCDay()

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.

getUTCDay() メソッドは、協定世界時に基づき、指定された日時の「曜日」を返します。0 は日曜日を表します。

試してみましょう

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");

// Tuesday
console.log(date1.getUTCDay());
// Expected output: 2

// Wednesday
console.log(date2.getUTCDay());
// Expected output: 3

構文

js
getUTCDay()

返値

数値です。 Date オブジェクトが有効な日時を表している場合、世界時で指定された日時の曜日を表した整数値(日曜日は 0、月曜日は 1、火曜日は 2、...)です。 それ以外の場合は、Date オブジェクトが有効な日時を表していなければ NaN が返されます。

getUTCDay() の使用

次の例は、現在日時の曜日の部分を変数 weekday に代入します。

js
const today = new Date();
const weekday = today.getUTCDay();

仕様書

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

ブラウザーの互換性

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
getUTCDay

Legend

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

Full support
Full support

関連情報