Get all months name from year in moment.js

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

    It's 2019 and you shouldn't be using moment.js anymore, since the vanilla Date() class has everything we need. Except for this little bit of functionality.

    Here's what I use: There's the months NPM module which has all months in different languages. It's about 991 bytes gzipped.

    Example with proper import syntax:

    import months from 'months'
    
    console.log(months.de)
    

    Result:

    [
      "Januar",
      "Februar",
      "März",
      "April",
      "Mai",
      "Juni",
      "Juli",
      "August",
      "September",
      "Oktober",
      "November",
      "Dezember"
    ]
    

提交回复
热议问题