JavaScript getUTCSeconds

JavaScript getUTCSeconds 函数是 Date 函数之一,它根据通用时间返回给定日期的总秒数。getUTCSeconds 函数的语法是:

 Date.getUTCSeconds()

我们使用 getUTCSeconds 来返回当前日期和时间的通用时间总秒数。

<!DOCTYPE html>
<html>
<head>
    <title> JS </title>
</head>
<body>
    <h1> Example </h1>
<script>
  var dt = Date();  
  document.write("Date and Time : " + dt);
  document.write("UTC Seconds : " + dt.getUTCSeconds());
</script>
</body>
</html>
Example

Date and Time: Mon Nov 05 2018 11:11:38 GMT+0530 (Indian Standard Time)
UTC Seconds : 38

在此 JavaScript get UTC Seconds 示例中,我们根据通用时间显示自定义日期和时间的秒数。

<!DOCTYPE html>
<html>
<head>
    <title> JavaScriptGetUTCSecondsFunction </title>
</head>
<body>
    <h1> JavaScriptgetUTCSecondsFunctionExample </h1>
<script>
  var dt = Date("April 2, 2017 10:02:22");
  document.write("Date and Time : " + dt);
  document.write("UTC Seconds using getUTCSeconds : " + dt.getUTCSeconds());
</script>
</body>
</html>
getUTCSeconds Function Example