How to use ToLocaleDateString in JavaScript

In this article I am going to explain about toLocaleDateString() method in JavaScript.
  • 1795

JavaScript toLocaleDateString() Method

JavaScript toLocaleDateString() method also use for convert date object in string format but its use locale date conventions for converting date object in sting format.

Syntax

Date.toLocalDateString()

Example

<html>

<head>

    <script type="text/javascript">

        function myfun() {

            var dd = new Date();

            var mm = document.getElementById("tst");

            mm.innerHTML = dd.toLocaleDateString();

        }

    </script>

</head>

<body>

    <p>

        click button to show Date</p>

    <h1 id="tst" style="color: Blue" s>

    </h1>

    <button onclick="myfun()">

        click me</button>

</body>

</html>

 

Output

 

 ToLocalDateString.jpg

 

You may also want to read these related articles: here
 
Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.