Date.prototype.getUTCMonth()

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.

getUTCMonth() メソッドは、協定世界時に基づき、指定された日付の「月」を表す 0 を基点とした値(すなわち 0 が年の最初の月を示す)を返します。

試してみましょう

const date1 = new Date("December 31, 1975, 23:15:30 GMT+11:00");
const date2 = new Date("December 31, 1975, 23:15:30 GMT-11:00");

// December
console.log(date1.getUTCMonth());
// Expected output: 11

// January
console.log(date2.getUTCMonth());
// Expected output: 0

構文

js
getUTCMonth()

返値

数値です。Date オブジェクトが有効な日時を表している場合、0 から 11 までの整数値で、指定された日時の月が世界時で何月になるかに対応します。0 は 1 月、1 は 2 月、2 は 3 月、といった具合になります。 数値です。それ以外の場合は、Date オブジェクトが有効な日時を表していなければ NaN が返されます。

getUTCMonth() の使用

次の例は、現在日時の「月」の部分を変数 month に代入します。

js
const today = new Date();
const month = today.getUTCMonth();

仕様書

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

ブラウザーの互換性

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
getUTCMonth

Legend

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

Full support
Full support

関連情報