Date getSeconds() Method - Javascript Date

Javascript examples for Date:getSeconds


The getSeconds() method returns the seconds from 0 to 59.



Return Value:

A Number, from 0 to 59, representing the seconds

The following code shows how to return the seconds, according to local time:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {/* ww  w . java 2 s  .co  m*/
    var d = new Date();
    var n = d.getSeconds();
    document.getElementById("demo").innerHTML = n;


Related Tutorials