How to use ToTimeString in JavaScript

In this article I am going to explain about to toTimeString() method in JavaScript.
  • 2195

JavaScript toTimeString() Method

JavaScript toTimeString() method use for convert time part of date object in string format. Its only work for Time not for Date.

Syntax

Date.toTimeString()

Example

<html>

<head>

    <script type="text/javascript">

        function myfun() {

            var dd = new Date();

            var mm = document.getElementById("tst");

            mm.innerHTML = dd.toTimeString();

        }

    </script>

</head>

<body>

    <p>

        click button to show Date</p>

    <h4 id="tst" style="color: Blue">

    </h4>

    <button onclick="myfun()">

        click me</button>

</body>

</html>

 

Output

 

 toTimeString.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
 

Categories

More Articles

© 2018 DotNetHeaven. All rights reserved.