moment.js, how to get day of week number

前端 未结 5 742
臣服心动
臣服心动 2020-12-09 00:53

I have a moment date object, and want to get the selected day number (0-6) or (1-7).

I tried this, but it doesn\'t work

var aaa = moment(date).day();         


        
5条回答
  •  一向
    一向 (楼主)
    2020-12-09 01:18

    I think this would work

    moment().weekday(); //if today is thursday it will return 4
    

提交回复
热议问题