試一試
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 |
瀏覽器相容性
載入中…