访问特定区域设置的功能



此处将看到当前加载区域设置中的可用方法和属性。

语法

moment.localeData()

当你控制台 moment.localeData() 时,你会在浏览器中看到以下输出 -

Accessing

示例

var localeData = moment.localeData();
var m = localeData.months();
var k = localeData.weekdays();

输出

Accessing Locale

可以使用 moment.localeData(‘property’) 访问这些属性。localeData 对象有以下可用方法 -

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

你还可以对 localeData 对象使用以下方法 -

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
广告