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

浏览器兼容性

另见