Get all months name from year in moment.js

后端 未结 9 914
执笔经年
执笔经年 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:55

    You are going to have to access the months from an array:

    var months = [ "January", "February", "March", "April", "May", "June",
    "July", "August", "September", "October", "November", "December" ];
    
    var monthInt = new Date().getMonth();
    var monthString = months[monthInt];
    

提交回复
热议问题