Home >>JavaScript Date Object Methods >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()
Method | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
getUTCSeconds() | Yes | Yes | Yes | Yes | Yes |
<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>
<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>