Gab
Gab

Reputation: 2276

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

Upvotes: 0

Views: 57

Answers (1)

jcubic
jcubic

Reputation: 66488

Try:

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

Upvotes: 1

Related Questions