MomentJS - normalizeUnits
此方法允许规范化程序中使用的单位。请注意,使用单位的方法(例如 moment().get('h') 或 moment().get('hours'))是相同的。
如果您想要定义单位的别名,可以使用 Normalize 方法。使用年份作为 y 或 YEar 或 yEARs 将使用 normalizeUnits 回退到年份。
语法
moment.normalizeUnits(String);
示例
moment.normalizeUnits('y');
moment.normalizeUnits('Y');
moment.normalizeUnits('yEar');
moment.normalizeUnits('yeArs');
moment.normalizeUnits('YeARS');
输出
示例
var m = moment.normalizeUnits('M');
var a = moment.normalizeUnits('MONTHS');
var b = moment.normalizeUnits('Months');
var c = moment.normalizeUnits('MonTh');
输出

momentjs_utilities.html