試一試
const moonLanding = new Date("July 20, 1969, 20:18:04 UTC");
console.log(moonLanding.getUTCSeconds());
// Expected output: 4
語法
js
getUTCSeconds()
引數
無。
返回值
一個介於 0 到 59 之間的整數,表示根據世界時給定的日期的秒數。如果日期 無效,則返回 NaN。
示例
使用 getUTCSeconds()
以下示例將當前時間的秒數部分賦給變數 seconds。
js
const today = new Date();
const seconds = today.getUTCSeconds();
規範
| 規範 |
|---|
| ECMAScript® 2026 語言規範 # sec-date.prototype.getutcseconds |
瀏覽器相容性
載入中…