Date getSeconds() Method - Javascript Date

Javascript examples for Date:getSeconds

Description

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

Parameters

None

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>
<html>
<body>

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

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

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

</body>
</html>

Related Tutorials