SQL PHP HTML ASP JavaScript articles and free scripts to download
 

toLocaleDateString()

We can convert any date object to local string by using toLcaleDateString like this

Date.toLocaleDateString

Here is a sample code

<script type="text/javascript">
var dt= new Date();
document.write(dt + "<br><br>");
document.write(dt.toLocaleDateString());
</script>

The output is here

What is the difference between toDateString and toLocaleDateString. Here is a comparison

<script type="text/javascript">
var dt= new Date();
document.write(dt + "<br><br>");
document.write(dt.toDateString() + "<br><br>");
document.write(dt.toLocaleDateString());
</script>

Check different outputs here




Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked

Join Our Email List
Email:  
For Email Newsletters you can trust
Date & Time