A RetroSearch Logo

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

Search Query:

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

Date.prototype.getUTCHours() - JavaScript | MDN

Date.prototype.getUTCHours()

Baseline Widely available

getUTCHours() は Date インスタンスのメソッドで、協定世界時に基づき、指定された日時の「時」を返します。

試してみましょう
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");

console.log(date1.getUTCHours());
// 予想される結果: 12

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

なし。

返値

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

例 getUTCHours() の使用

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

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

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