getUTCSeconds 方法 (Date)

使用协调通用时间(UTC)获取Date对象中的秒数。

语法

dateObj.getUTCSeconds()

参数

必需的dateObj引用是Date对象。

返回值

返回0和59之间的整数。当到当前分钟的时间小于一秒时,返回0。如果创建Date对象时,未指定时间,默认情况下UTC的秒钟值是0。

备注

若要获取用当地时间表示的秒数,请使用getSeconds方法。

示例

下面的示例演示如何使用getUTCSeconds方法。

var date = new Date("1/1/2001");
document.write(date. getUTCSeconds());
// Output: 0

必备条件

在以下文档模式中受支持:怪异模式、Internet Explorer 6标准模式、Internet Explorer 7标准模式、Internet Explorer 8标准模式、Internet Explorer 9标准模式、Internet Explorer 10标准模式、Internet Explorer 11标准模式。应用商店应用(Windows 8和Windows Phone 8.1)中也受支持。请参阅版本信息

Applies ToDate Object

如果你喜欢这篇文章,敬请给站长打赏↑

除特别注明外,本站所有文章均为本站站长原译,转载请注明出处。