Date.prototype.getUTCMinutes()

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2015 年 7 月⁩以來,各瀏覽器均已提供此特性。

getUTCMinutes() 方法是 Date 物件的一個例項方法,它根據世界協調時間(UTC)返回日期中的分鐘數。

試一試

const date1 = new Date("1 January 2000 03:15:30 GMT+07:00");
const date2 = new Date("1 January 2000 03:15:30 GMT+03:30");

console.log(date1.getUTCMinutes()); // 31 Dec 1999 20:15:30 GMT
// Expected output: 15

console.log(date2.getUTCMinutes()); // 31 Dec 1999 23:45:30 GMT
// Expected output: 45

語法

js
getUTCMinutes()

引數

無。

返回值

返回值為一個介於 0 和 59 之間的整數,表示給定日期根據世界協調時間(UTC)的分鐘數。如果日期 無效,則返回 NaN

示例

使用 getUTCMinutes()

下面的示例將當前時間的分鐘部分賦值給變數 minutes

js
const today = new Date();
const minutes = today.getUTCMinutes();

規範

規範
ECMAScript® 2026 語言規範
# sec-date.prototype.getutcminutes

瀏覽器相容性

另見