If you're trying to format times for tweets like the way Twitter does, you can use the moment.twitter plugin by @hijonathan.
It's a simple way to display both short and long versions of human-readable timestamps.
moment().subtract(5, 'hours').twitterLong();
// 5 hours
Yes, it does smart pluralization.
moment().subtract(1, 'hour').twitterLong();
// 1 hour
Not short enough for you?
moment().subtract(6, 'days').twitterShort();
// 6d
当前内容版权归 momentjs.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 momentjs.com .