Date.prototype.getUTCSeconds()

Date 实例的 getUTCSeconds() 方法根据世界时间返回指定日期的秒数。

¥The getUTCSeconds() method of Date instances returns the seconds in the specified date according to universal time.

Try it

语法

¥Syntax

js
getUTCSeconds()

参数

¥Parameters

没有任何。

¥None.

返回值

¥Return value

0 到 59 之间的整数,表示根据通用时间给定日期的秒数。如果日期是 invalid,则返回 NaN

¥An integer, between 0 and 59, representing the seconds for the given date according to universal time. Returns NaN if the date is invalid.

示例

¥Examples

使用 getUTCSeconds()

¥Using getUTCSeconds()

以下示例将当前时间的秒部分分配给变量 seconds

¥The following example assigns the seconds portion of the current time to the variable seconds.

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

规范

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

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看