Categories
JavaScript Answers

How to convert a full date to a short date in JavaScript?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *