Get UTC seconds:
const d = new Date();
let seconds = d.getUTCSeconds();
Try it Yourself »
Using getUTC methods to display the universal time:
function addZero(i) {
if (i < 10) {i = "0" + i}
return i;
}
const d = new Date();
let h = addZero(d.getUTCHours());
let m = addZero(d.getUTCMinutes());
let s = addZero(d.getUTCSeconds());
let time = h + ":" + m + ":" + s;
Try it Yourself »
getUTCSeconds()
returns the seconds (0 to 59) of a date.
getUTCSeconds()
returns the seconds according to UTC.
UTC (Universal Time Coordinated) is the time set by the World Time Standard.
UTC time is the same as GMT time (Greenwich Mean Time).
All JavaScript getUTC methods assume that the date is of local time.
Date.getUTCSeconds()
NONE |
Type | Description |
A number | The seconds of the date (0 to 59). |
getUTCSeconds()
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!