- MomentJS Tutorial
- MomentJS - Home
- MomentJS - Overview
- MomentJS - Environment Setup
- MomentJS - Introduction
- MomentJS - Parsing Date And Time
- MomentJS - Date Validation
- MomentJS - Getter/Setter
- Manipulate Date And Time
- Formatting Date And Time
- MomentJS - Date Queries
- MomentJS - Internationalization
- MomentJS - Customization
- MomentJS - Durations
- MomentJS - Utilities
- MomentJS - Plugins
- MomentJS - Examples
- MomentJS Useful Resources
- MomentJS - Quick Guide
- MomentJS - Useful Resources
- MomentJS - Discussion
MomentJS - Month Abbreviation
This method helps in customizing the month abbreviations.
Syntax
moment.updateLocale('en', { monthsShort : String[] }); moment.updateLocale('en', { monthsShort : Function }); moment.updateLocale('en', { monthsShort : { format: String[], standalone : String[] } });
Example
var localeData = moment.updateLocale('en', { monthsShort : ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] }); var m = localeData.monthsShort();
Output
Example
var localeData = moment.updateLocale('en', { nominative: 'Jan_Feb_Mar_Apr_May_June_July_Aug_Sept_Oct_Nov_Dec'.split('_'), subjective: 'Jan_Feb_Mar_Apr_May_June_July_Aug_Sept_Oct_Nov_Dec'.split('_'), monthsShort: function (momentToFormat, format) { if (/^MMMM/.test(format)) { console.log(this._nominative); return this._nominative[momentToFormat.month()]; } else { return this._subjective[momentToFormat.month()]; } } }); var m = localeData.monthsShort(moment(), "MMMM");
Output
Example
var localeData = moment.updateLocale('en', { monthsShort : { format: 'jan_feb_mar_apr_may_june_july_aug_sept_oct_nov_dec'.split('_'), standalone: 'jan_feb_mar_apr_may_june_july_aug_sept_oct_nov_dec'.split('_') } }); var m = localeData.monthsShort();
Output
momentjs_customization.htm
Advertisements
To Continue Learning Please Login
Login with Google