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.
1 Answer
Reset to default 6try
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条)