- 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
Listing date/time details of current locale
You can set the locale and check the details like months, weekdays etc. In the examples given here, we have set the locale to French and below example shows the months, weekdays for French locale.
Locale Month
This method will get the months for the locale set.
Syntax
moment.months(); moment.monthsShort();
Example
moment.locale('fr'); var m = moment.months(); JSON.stringify(m);
Output
Example
moment.locale('fr'); var m = moment.monthsShort(); JSON.stringify(m);
Output
Weekdays
Syntax
moment.weekdays() moment.weekdaysShort() moment.weekdaysMin()
Example
moment.locale('fr'); var m = moment.weekdays(); JSON.stringify(m);
Output
Example
moment.locale('fr'); var m = moment.weekdaysShort(); JSON.stringify(m);
Output
Example
moment.locale('fr'); var m = moment.weekdaysMin(); JSON.stringify(m);
Output
Example
moment.locale('fr'); var m = moment.weekdays(4);
The above examples displays the fourth day of the week.
Output
Example
moment.locale('fr'); var m = moment.weekdays(true);
The locale is set to French. When true is passed to weekdays it will display the output as Saturday to Friday in French.
Output
Example
moment.locale('fr'); var m = moment.weekdays(true, 1);
It will display Sunday as per French.
Output
momentjs_internationalization.htm
Advertisements