MomentJS - Humaniser

Cette méthode affiche la date dans un format lisible par l'homme.

Syntaxe

moment.duration().humanize();

Exemple

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

Production

Au cas où vous auriez besoin d'un suffixe tel que ago ou in à la sortie, ajoutez true pour humaniser comme suit

Exemple

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

Production

Exemple

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

Production