javascript - Moment js Not returning the right day of the week - Stack Overflow

I am trying to use Momentjs to return the day of the week (ex. "monday" or "mon", d

I am trying to use Momentjs to return the day of the week (ex. "monday" or "mon", doesn't matter as long as it's the name of the day of the week) for the string number that I stored in the db (ex "3"). For some reason I keep getting Monday returned.

var values = ["3", "06:00", "18:00"];
moment().isoWeekday(values[0]).format('ddd');
//returns "Mon"

I've also tried using moment('3','d').format('ddd')
I've also tried using moment().days('3').format('ddd')
Always returns the same day. Usually Sat or Mon.

I am trying to use Momentjs to return the day of the week (ex. "monday" or "mon", doesn't matter as long as it's the name of the day of the week) for the string number that I stored in the db (ex "3"). For some reason I keep getting Monday returned.

var values = ["3", "06:00", "18:00"];
moment().isoWeekday(values[0]).format('ddd');
//returns "Mon"

I've also tried using moment('3','d').format('ddd')
I've also tried using moment().days('3').format('ddd')
Always returns the same day. Usually Sat or Mon.

Share Improve this question asked Aug 26, 2013 at 14:23 JohnstonJohnston 20.9k22 gold badges76 silver badges124 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

try

moment().isoWeekday(parseInt(values[0])).format('ddd');

And in general, store the week day as integer and not string:

var values = [3, "06:00", "18:00"];

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745248654a4618539.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信