Date.prototype.getMinutes()

Baseline 已廣泛支援

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

getMinutes() 方法用於 Date 例項,根據本地時間返回此日期的分鐘數。

試一試

const birthday = new Date("March 13, 08 04:20");

console.log(birthday.getMinutes());
// Expected output: 20

語法

js
getMinutes()

引數

無。

返回值

一個整數,介於 0 到 59 之間,表示給定日期根據本地時間的分鐘數。如果日期 無效,則返回 NaN

示例

使用 getMinutes()

基於 Date 物件 xmas95 的值,變數 minutes 的值為 15

js
const xmas95 = new Date("1995-12-25T23:15:30");
const minutes = xmas95.getMinutes();

console.log(minutes); // 15

規範

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

瀏覽器相容性

另見