Date.prototype.getSeconds()
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.
getSeconds()
方法基於本地時區回傳指定日期的秒數。
嘗試一下
語法
js
getSeconds()
返回值
一個基於本地時區表示指定日期的秒數、介於 0 至 59 的整數值。
範例
使用 getSeconds()
下方第二行陳述式將 Date
物件 xmas95
的值 30,指派給變數 seconds
。
js
const xmas95 = new Date("December 25, 1995 23:15:30");
const seconds = xmas95.getSeconds();
console.log(seconds); // 30
規範
Specification |
---|
ECMAScript Language Specification # sec-date.prototype.getseconds |
瀏覽器相容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
getSeconds |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.