Date toLocaleDateString() Method - Javascript Date

Javascript examples for Date:toLocaleDateString


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>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

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;


Related Tutorials