Date.prototype.getUTCMinutes()

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.

getUTCMinutes() 方法根據世界時回傳指定日期的分鐘數。

嘗試一下

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()

返回值

Date 物件為有效日期,則根據 UTC 時間回傳一個表示分鐘數、介於 0 至 59 之間的整數;若為無效日期,則回傳 Number.NaN()

範例

使用 getUTCMinutes()

下列範例指派當前時間的分鐘至變數 minutes

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

規範

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

瀏覽器相容性

參見