- MomentJS 教程
- MomentJS - 主頁
- MomentJS - 概述
- MomentJS - 環境設定
- MomentJS - 簡介
- MomentJS - 解析日期和時間
- MomentJS - 日期驗證
- MomentJS - 獲取器/設定器
- 操作日期和時間
- 格式化日期和時間
- MomentJS - 日期查詢
- MomentJS - 國際化
- MomentJS - 自定義
- MomentJS - 持續時間
- MomentJS - 實用程式
- MomentJS - 外掛
- MomentJS - 示例
- MomentJS 有用資源
- MomentJS - 快速指南
- MomentJS - 有用的資源
- MomentJS - 討論
MomentJS - 相對時間
此方法有助於獲取相對時間。
語法
moment.updateLocale('en', {
relativeTime : Object
});
示例
var localeData = moment.updateLocale('en', {
relativeTime: {
future: "in %s",
past: "%s ago",
s: 'hello, a few seconds',
ss: '%d seconds',
m: "a minute",
mm: "%d minutes",
h: "an hour",
hh: "%d hours",
d: "a day",
dd: "%d days",
M: "a month",
MM: "%d months",
y: "a year",
yy: "%d years"
}
});
var m = moment().fromNow();
輸出
momentjs_customization.htm
廣告