Sometimes, we want to get day name from date with Moment.js and JavaScript.
In this article, we’ll look at how to get day name from date with Moment.js and JavaScript.
How to get day name from date with Moment.js and JavaScript?
To get day name from date with Moment.js and JavaScript, we can use the format method.
For instance, we write
const myDate = "2022-06-28T00:00:00";
const weekDayName = moment(myDate).format("dddd");
console.log(weekDayName);
to call moment with the myDate string to parse myDate to a moment object.
Then we call format with the 'dddd' string to return a string with the day name for the myDate date.
Conclusion
To get day name from date with Moment.js and JavaScript, we can use the format method.