Javascript examples for Date:toLocaleString
The toLocaleString() method converts a Date object to a string, using locale settings.
A String, representing the date and time as a string
The following code shows how to Convert a Date object to a string, using locale conventions:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w ww .ja v a 2s. co m*/ var d = new Date(); var n = d.toLocaleString(); document.getElementById("demo").innerHTML = n; } </script> </body> </html>