I am using momentjs
and want to output the name of the day ie. "Wednesday" but the API only seems to offer a number.
Is there a way to do this without hard-coding it to a particular language?
Syntax. moment(). weekday(Number); moment(). weekday();
The moment(). hour() Method is used to get the hours from the current time or to set the hours. moment().
Moment construction falls back to js Date. This is discouraged and will be removed in an upcoming major release. This deprecation warning is thrown when no known format is found for a date passed into the string constructor.
Moment. js is a fantastic time & date library with lots of great features and utilities. However, if you are working on a performance sensitive web application, it might cause a huge performance overhead because of its complex APIs and large bundle size.
From the Format section of their documentation:
Day of Week
dddd
Sunday Monday ... Friday Saturday
moment().format('dddd');
In case, if you want to get a name out of an index day
const day = 1; //second index after 0
moment().day(day).format("dddd") //Monday
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With