Sometimes, we want to find the day, month and year with moment.js and JavaScript.
In this article, we’ll look at how to find the day, month and year with moment.js and JavaScript.
How to find the day, month and year with moment.js and JavaScript?
To find the day, month and year with moment.js and JavaScript, we can use the date, month, and year methods.
For instance, we write
const date = moment().date();
const month = moment().month();
const year = moment().year();
to call moment to return a moment object with the current date and time.
Then we call date to return the day of the month.
We call month to return the month. month returns 0 for January and up to 11 for December.
And we call year to return the year.
Conclusion
To find the day, month and year with moment.js and JavaScript, we can use the date, month, and year methods.