How to format a date DD/MM/YYYY into format in Moment.js and JavaScript?

Sometimes, we want to format a date DD/MM/YYYY into format in Moment.js and JavaScript.

In this article, we’ll look at how to format a date DD/MM/YYYY into format in Moment.js and JavaScript.

How to format a date DD/MM/YYYY into format in Moment.js and JavaScript?

To format a date DD/MM/YYYY into format in Moment.js and JavaScript, we use the format method.

For instance, we write

const searchDate = moment(new Date()).format("DD/MM/YYYY");

to call moment with a date to convert it to a moment object.

Then we call format with the "DD/MM/YYYY" format string to return a date string in the DD/MM/YYYY format.

Conclusion

To format a date DD/MM/YYYY into format in Moment.js and JavaScript, we use the format method.