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
广告
© . All rights reserved.