Javascript examples for Date:toLocaleDateString
The toLocaleDateString() method converts the date of a Date object into a readable string, using locale conventions.
A String, representing the date as a string
The following code shows how to return the Date object as a string, using locale conventions:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from www. j a v a 2 s. co m var d = new Date(); var n = d.toLocaleDateString(); document.getElementById("demo").innerHTML = n; } </script> </body> </html>