Javascript examples for Date:toString
The toString() method converts a Date object to a string.
This method is called whenever a Date object needs to be displayed as a string.
None
A String, representing the date and time as a string
The following code shows how to Convert a Date object to a string:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w w w . j a va 2 s. c om*/ var d = new Date(); var n = d.toString(); document.getElementById("demo").innerHTML = n; } </script> </body> </html>