Javascript examples for Date:toTimeString
The toTimeString() method converts the time portion of a Date object to a string.
None
A String, representing the time as a string
The following code shows how to Convert the time portion of a Date object to a string:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//w ww . j a v a2 s. com var d = new Date(); var n = d.toTimeString(); document.getElementById("demo").innerHTML = n; } </script> </body> </html>