Categories
JavaScript Answers

How to fix .day() returns wrong day of month with Moment.js and JavaScript?

Spread the love

Sometimes, we want to fix .day() returns wrong day of month with Moment.js and JavaScript.

In this article, we’ll look at how to fix .day() returns wrong day of month with Moment.js and JavaScript.

How to fix .day() returns wrong day of month with Moment.js and JavaScript?

To fix .day() returns wrong day of month with Moment.js and JavaScript, we should use the date method instead of day.

For instance, we write

const today = moment().date();

to call date to return the day of the month of today.

Conclusion

To fix .day() returns wrong day of month with Moment.js and JavaScript, we should use the date method instead of day.

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 *