Date.prototype.getUTCSeconds()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

getUTCSeconds() 方法根據世界時回傳指定日期的秒數。

嘗試一下

語法

js
getUTCSeconds()

返回值

Date 物件為有效日期,則根據 UTC 時間回傳一個表示秒數、介於 0 至 59 之間的整數;若為無效日期,則回傳 Number.NaN()

範例

使用 getUTCSeconds()

下列範例指派當前時間的秒數至變數 seconds

js
const today = new Date();
const seconds = today.getUTCSeconds();

規範

Specification
ECMAScript Language Specification
# sec-date.prototype.getutcseconds

瀏覽器相容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
getUTCSeconds

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

參見