Get all months name from year in moment.js
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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? 回答1: There happens to be a function for that: moment.monthsShort() // ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"] Or the same using manual formatting: Array.apply(0, Array(12