Get month name from two digit month number

后端 未结 4 1063
既然无缘
既然无缘 2021-02-02 09:26

I want to get month name from two digit month number (ex- 09). I tried with this code. But it doesn\'t work. The code give current month name only. What are the correct code for

4条回答
  •  悲哀的现实
    2021-02-02 10:20

    You want to pass the month when you create the Moment object:

    var formattedMonth = moment('09', 'MM').format('MMMM'); // September
    
    moment(
        '09',           // Desired month
        'MM'            // Tells MomentJs the number is a reference to month
    ).format('MMMM')    // Formats month as name
    

提交回复
热议问题