试一试
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 |
浏览器兼容性
加载中…