MomentJS - Humanize
此方法以人类可读的格式显示日期。
语法
moment.duration().humanize();
示例
var a = moment.duration(24, "hours").humanize();
输出
如果您需要在输出中添加 ago 或 in 等后缀,请按如下方式添加 true 以进行人性化
示例
var a = moment.duration(24, "hours").humanize(true);
输出
示例
var a = moment.duration(-1, "days").humanize(true);