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 code, but it's not working for me.
var xxx = moment().months(2011);
Showing result is
also i have tried xxx.months()
, but it's return result is 7
but i want jan,feb,mar,......dec
. hmm What can i do?
Using moment.js you have the following methods:
returns:
and
returns:
Output
You can use following function to get a list of Weekdays and Months for listing purpose -
You can check live example here - Localized Month and Weekdays List
Why does the year matter? Month names don't change.
You could get month names from Moment like so:
You are going to have to access the months from an array:
There happens to be a function for that:
Or the same using manual formatting:
I guess you want to display all names utilizing Moment.js locale data, which is a reasonable approach.