Date toLocaleDateString() Method - Javascript Date

Javascript examples for Date:toLocaleDateString

Description

The toLocaleDateString() method converts the date of a Date object into a readable string, using locale conventions.

Return Value:

A String, representing the date as a string

The following code shows how to return the Date object as a string, using locale conventions:

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials