Date toLocaleString() Method - Javascript Date

Javascript examples for Date:toLocaleString

Description

The toLocaleString() method converts a Date object to a string, using locale settings.

Return Value:

A String, representing the date and time as a string

The following code shows how to Convert a Date object to 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 w  ww .ja  v  a 2s.  co m*/
    var d = new Date();
    var n = d.toLocaleString();
    document.getElementById("demo").innerHTML = n;
}
</script>

</body>
</html>

Related Tutorials