JavaScript getUTCSeconds

JavaScript getUTCSeconds function is one of the Date Functions, which returns the total seconds on a given date according to universal time. The syntax of the getUTCSeconds function is:

 Date.getUTCSeconds()

JavaScript getUTCSeconds Example

We use getUTCSeconds to return the total seconds as per the universal time from the current date and time.

<!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

Example 2

In this JavaScript example for get UTC Seconds, we display the seconds from the custom date and time as per universal time.

<!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>
JavaScript getUTCSeconds Example