A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth below:

Date.prototype.getUTCMonth() - JavaScript | MDN

Date.prototype.getUTCMonth()

Baseline Widely available

getUTCMonth() は Date インスタンスのメソッドで、協定世界時に基づき、指定された日時の「月」を表す 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());
// 予想される結果: 11

// January
console.log(date2.getUTCMonth());
// 予想される結果: 0
構文 引数

なし。

返値

指定された日時の、協定世界時に基づく「月」を表す 0 から 11 までの整数です。1 月ならば 0、 2 月ならば 1 となります。日時が無効な場合は NaN を返します。

例 getUTCMonth() の使用

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

const today = new Date();
const month = today.getUTCMonth();
仕様書 ブラウザーの互換性 関連情報

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4