MomentJS - 人性化



此方法以人類可讀的格式顯示日期。

語法

moment.duration().humanize();

示例

var a = moment.duration(24, "hours").humanize();

輸出

Humanize

如果您需要在輸出中新增字尾,例如 **之前** 或 **後**,請向 humanize 新增 true,如下所示

示例

var a = moment.duration(24, "hours").humanize(true);

輸出

Humanize Hours

示例

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

輸出

Humanize Days
momentjs_durations.htm
廣告