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.