Sometimes, we want to convert a full date to a short date in JavaScript.
In this article, we’ll look at how to convert a full date to a short date in JavaScript.
How to convert a full date to a short date in JavaScript?
To convert a full date to a short date in JavaScript, we use the toLocaleDateString
method.
For instance, we write
const date = new Date().toLocaleDateString("en-US");
to call toLocaleDateString
with the locale string to return a string with the short form of the current date.
Conclusion
To convert a full date to a short date in JavaScript, we use the toLocaleDateString
method.