- 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
Accessing Locale Specific Functionality
Here will see the methods and properties available on currently loaded locale.
Syntax
moment.localeData()
You will observe the following output in the browser when we console moment.localeData() −
Example
var localeData = moment.localeData(); var m = localeData.months(); var k = localeData.weekdays();
Output
The properties can be accessed using moment.localeData(‘property’). The following methods are available from localeData object −
var localeData = moment.localeData(); var m = localeData.months(moment()); // gets the month as per the moment such as April var m1 = localeData.monthsShort(moment()); // gets the month name in shortform such as Apr var k = localeData.weekdays(moment()); // returns the weekday for given moment.such as Monday var k1 = localeData.weekdaysShort(moment()); // returns shortname for weekday for given moment.such as Mon
You can also use the following methods on localeData object −
localeData.weekdaysMin(aMoment); localeData.weekdaysParse(minShortOrLongWeekdayString); localeData.longDateFormat(dateFormat); localeData.isPM(amPmString); localeData.meridiem(hours, minutes, isLower); localeData.calendar(key, aMoment); localeData.relativeTime(number, withoutSuffix, key, isFuture); localeData.pastFuture(diff, relTime); localeData.ordinal(number); localeData.preparse(str); localeData.postformat(str); localeData.week(aMoment); localeData.invalidDate(); localeData.firstDayOfWeek(); localeData.firstDayOfYear();
momentjs_internationalization.htm
Advertisements