MomentJS - Humanize



This method displays the date in human readable format.

Syntax

moment.duration().humanize();

Example

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

Output

Humanize

In case you need suffix such as ago or in to the output, add true to humanize as follows

Example

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

Output

Humanize Hours

Example

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

Output

Humanize Days
momentjs_durations.htm
Advertisements