- MomentJS 教程
- MomentJS - 主页
- MomentJS - 概述
- MomentJS - 环境设置
- MomentJS - 简介
- MomentJS - 解析日期和时间
- MomentJS - 日期校验
- MomentJS - Getter/Setter
- 操作日期和时间
- 格式化日期和时间
- MomentJS - 日期查询
- MomentJS - 国际化
- MomentJS - 自定义
- MomentJS - 时长
- MomentJS - 实用程序
- MomentJS - 插件
- MomentJS - 示例
- MomentJS 有用资源
- MomentJS - 快速指南
- MomentJS - 有用资源
- MomentJS - 讨论
MomentJS - 月份名称
您可以在区域设置自定义中添加月份名称。
语法
moment.updateLocale('en', { months : String[] });
或
moment.updateLocale('en', { months : Function });
或
moment.updateLocale('en', { months : { format : String[], standalone : String[] } });
示例
var localeData = moment.updateLocale('fr', { months: [ "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec" ] }); var m = localeData.months();
输出
示例
var localeData = moment.updateLocale('en', { nominative: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), subjective: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), months: 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.months(moment(), "MMMM");
输出
示例
var localeData = moment.updateLocale('en', { months : { format: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), standalone: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), isFormat: /D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?|MMMM?(\[[^\[\]]*\]|\s+)+D[oD]?/ // from 2.14.0 } }); var m = localeData.months();
输出
momentjs_customization.htm
广告