Home >>JavaScript Date Object Methods >JavaScript toLocaleDateString() Method
JavaScript toLocaleDateString() methodis an inbuilt method in JavaScript which is used to converts the date(not the time) of a Date object in the form of string.
Syntax:Date.toLocaleDateString()
Method | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
toLocaleDateString() | Yes | Yes | Yes | Yes | Yes |
<html> <body> <script> var d=new Date(); document.writeln(d.toDateString()); </script> </body> </html>
<html> <body> <button onclick="mytoLocaleDstring()">click me</button> <p id="Dstring"></p> <script> function mytoLocaleDstring() { var x = new Date(); var y = x.toLocaleDateString(); document.getElementById("Dstring").innerHTML = y; } </script> </body> </html>