Prev Demo
JavaScript
>
Tolocalestring() Method
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>toLocaleString()</h1> <p>Click the below button to convert a date object into string, using Locale settings.</p> <input type="button" value="Click" onclick="myDate()" /> <p id="myId"></p> <script> var a = new Date(); //* Returns the date & time as per the internet network *// alert(a); //* Displays the Var A result in the alert box *// function myDate() { var r = a.toLocaleString(); //* Converts a date object into string using locale settings *// document.getElementById("myId").innerHTML = r; } </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output