Get all months name from year in moment.js

后端 未结 9 935
执笔经年
执笔经年 2020-12-14 07:31

I want to get all months name from year in moment.js

if the year is 2011, then i want to all months name in momentjs

i have tried this below

9条回答
  •  旧巷少年郎
    2020-12-14 08:00

    if the year is 2011, then i want to all months name in momentjs

    Why does the year matter? Month names don't change.

    You could get month names from Moment like so:

    var m = moment();
    for (var i = 0; i < 12; i++) {
     console.log(m.months(i).format('MMMM'));
    }
    

提交回复
热议问题