简体   繁体   中英

Getting the day of the week using the corresponding number and moment.js

I'm trying the retrieve the corresponding day of the week using moment.js

// e.dayOfTheWeek = 2;

let dayOfTheWeek = moment().day(e.dayOfTheWeek);

console.log(dayOfTheWeek);

returns the following

Moment {_isAMomentObject: true, _isUTC: false, _pf: Object, _locale: Locale, _d: Tue Mar 01 2016 13:35:40 GMT-0500 (Eastern Standard Time)…}

Would like it to return Tuesday what am I doing wrong?

also tried let dayOfTheWeek = moment().isoWeekday(e.dayOfTheWeek); same result

尝试:

moment().isoWeekday(e.dayOfTheWeek).format('dddd')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM