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