Get all months name from year in moment.js

后端 未结 9 961
执笔经年
执笔经年 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 07:58

    You can use following function to get a list of Weekdays and Months for listing purpose -

    var iIndex, 
    sArrMonths, sMonth;
    for(iIndex = 0; iIndex < 12; iIndex++)
    {
        sMonth = moment.localeData().months(moment([0,iIndex]), "");
        sArrMonths.push(sMonth);
    }
    

    You can check live example here - Localized Month and Weekdays List

提交回复
热议问题