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
Change the date object to time string →
← Date Reference
← Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
plus2net.com