How to use getSeconds in JavaScript

In this article, I will explain use of getSeconds() Method in JavaScript.
  • 1695

JavaScript date getSeconds() method

  • getSeconds() method of date object returns the seconds of the specified date according local time.

  • In getSeconds() method, The returned value is an integer number between 0 and 59.

Syntax

Date.getSeconds()

Example

In the following example show to getSeconds() method returns current time of seconds.

<!DOCTYPE html>

<html>

<body>

<h3 style="color:red">JavaScript getSecond() Method Example</h3>

<p id="demo">Click For display Current Time Of Second</p>

<button onclick="myFunction()">Click On</button>

<script type="text/javascript">

    function myFunction() {

        var d = new Date();

        var x = document.getElementById("demo");

        //x.innerHTML = d.getSeconds();

        document.write("Current Time Second is: " + d.getSeconds());

    }

</script>

</body>

</html>

Output1

getSecond 1.jpg

Output2

getSecond 2.jpg

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.