
- MomentJS 教程
- MomentJS - 主頁
- MomentJS - 概述
- MomentJS - 環境設定
- MomentJS - 簡介
- MomentJS - 解析日期和時間
- MomentJS - 日期有效性檢查
- MomentJS - 獲取器/設定器
- 操作日期和時間
- 格式化日期和時間
- MomentJS - 日期查詢
- MomentJS - 國際化
- MomentJS - 自定義設定
- MomentJS - 時間間隔
- MomentJS - 實用工具
- MomentJS - 外掛
- MomentJS - 示例
- MomentJS 有用資源
- MomentJS - 快速指南
- MomentJS - 有用資源
- MomentJS - 討論
MomentJS - 人性化
此方法以人類可讀的格式顯示日期。
語法
moment.duration().humanize();
示例
var a = moment.duration(24, "hours").humanize();
輸出

如果您需要在輸出中新增字尾,例如 **之前** 或 **後**,請向 humanize 新增 true,如下所示
示例
var a = moment.duration(24, "hours").humanize(true);
輸出

示例
var a = moment.duration(-1, "days").humanize(true);
輸出

momentjs_durations.htm
廣告