
- MomentJS Tutorial
- MomentJS - Home
- MomentJS - Overview
- MomentJS - Environment Setup
- MomentJS - Introduction
- MomentJS - Parsing Date And Time
- MomentJS - Date Validation
- MomentJS - Getter/Setter
- Manipulate Date And Time
- Formatting Date And Time
- MomentJS - Date Queries
- MomentJS - Internationalization
- MomentJS - Customization
- MomentJS - Durations
- MomentJS - Utilities
- MomentJS - Plugins
- MomentJS - Examples
- MomentJS Useful Resources
- MomentJS - Quick Guide
- MomentJS - Useful Resources
- MomentJS - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
MomentJS - Humanize
This method displays the date in human readable format.
Syntax
moment.duration().humanize();
Example
var a = moment.duration(24, "hours").humanize();
Output

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

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

momentjs_durations.htm
Advertisements