Categories
JavaScript Answers

How to get the current date in DD-Mon-YYYY format in JavaScript?

Spread the love

Sometimes, we want to get the current date in DD-Mon-YYY format in JavaScript.

In this article, we’ll look at how to get the current date in DD-Mon-YYY format in JavaScript.

How to get the current date in DD-Mon-YYY format in JavaScript?

To get the current date in DD-Mon-YYY format in JavaScript, we call the format method.

For instance, we write

const dateStr = moment().format("DD-MMM-YYYY");

to call moment to return a moment object with the current date time.

And then we call format to return a string in the DD-Mon-YYYY format.

Conclusion

To get the current date in DD-Mon-YYY format in JavaScript, we call the format 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 *