Home >>JavaScript Date Object Methods >JavaScript getUTCSeconds() Method

JavaScript getUTCSeconds() Method

JavaScript getUTCSeconds() Method

JavaScript getUTCSeconds() method returns the seconds ( from 0 to 59) in the specified date according to universal time. This method representing the seconds in the given date.

Syntax:
Date.getUTCSeconds()

Browser Support

Method Chrome Edge Firefox Safari Opera
getUTCSeconds() Yes Yes Yes Yes Yes
Here is an example of JavaScript getUTCSeconds() Method:
<html>
<body>
<button onclick="myGetsec()">click me</button>
<p id="sec"></p>
<script>
function myGetsec() 
{
  var d = new Date();
  var a = d.getUTCSeconds();
  document.getElementById("sec").innerHTML = a;
}
</script>
</body>
</html>
Output:

Example 2:
<html>
<body>
<script>
var sec1=new Date("Febuary 25 1997 23:20:45 GMT+7:00");
var sec2=new Date("Febuary 25 1997 23:59:58 GMT+5:30");
document.writeln("Second v1 : "+sec1.getUTCSeconds()+"<br>");
document.writeln("Second v2 : "+sec2.getUTCSeconds());
</script>
</body>
</html>
Output:

No Sidebar ads