JavaScript日期getUTCSeconds()方法 (JavaScript Date getUTCSeconds() method)
getUTCSeconds() method is a Date's class method and it is used to get seconds from the current time according to the UTC (Universal time coordinated).
getUTCSeconds()方法是Date的类方法,用于根据UTC(协调世界时)从当前时间获取秒。
Syntax:
句法:
var dt = new Date();
dt.getUTCSeconds();
Examples:
例子:
Input:
var dt = new Date();
dt.getUTCSeconds();
Output:
36
JavaScript code to get the current UTC seconds using getUTCSeconds() method
使用getUTCSeconds()方法获取当前UTC秒JavaScript代码
<html>
<head><title>JavaScipt Example</title></head>
<body>
<script>
var dt = new Date(); //Date constructor
var Seconds1 = dt.getUTCSeconds(); //UTC Seconds
var Seconds2 = dt.getSeconds(); //local Seconds
//printing Seconds
document.write("UTC Seconds = " + Seconds1 + "<br>");
document.write("Local Seconds = " + Seconds2 + "<br>");
</script>
</body>
</html>
Output
输出量
UTC Seconds = 37
Local Seconds = 37
Reference: JavaScript getUTCSeconds() Method
参考: JavaScript getUTCSeconds()方法
翻译自: https://www.includehelp.com/code-snippets/date-getUTCSeconds-method-with-example-in-javascript.aspx