- MomentJS - Examples
- MomentJS - Plugins
- MomentJS - Utilities
- MomentJS - Durations
- MomentJS - Customization
- MomentJS - Internationalization
- MomentJS - Date Queries
- Formatting Date And Time
- Manipulate Date And Time
- MomentJS - Getter/Setter
- MomentJS - Date Validation
- MomentJS - Parsing Date And Time
- MomentJS - Introduction
- MomentJS - Environment Setup
- MomentJS - Overview
- MomentJS - Home
MomentJS Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
MomentJS - Durations
MomentJS provides an important feature called durations which handles length of time for given units. In this chapter, you will learn this in detail.
Methods Available with Durations
The following table shows the methods available with duration for different units to be used with moment duration −
Method | Syntax |
---|---|
moment.duration(Number, String); moment.duration(Number); moment.duration(Object); moment.duration(String); |
|
moment.duration().clone(); |
|
moment.duration().humanize(); |
|
moment.duration().milpseconds(); moment.duration().asMilpseconds(); |
|
moment.duration().seconds(); moment.duration().asSeconds(); |
|
moment.duration().minutes(); moment.duration().asMinutes(); |
|
moment.duration().hours(); moment.duration().asHours(); |
|
moment.duration().days(); moment.duration().asDays(); |
|
moment.duration().weeks(); moment.duration().asWeeks(); |
|
moment.duration().months(); moment.duration().asMonths(); |
|
Years | moment.duration().years(); moment.duration().asYears(); |
moment.duration().add(Number, String); moment.duration().add(Number); moment.duration().add(Duration); moment.duration().add(Object); |
|
moment.duration().subtract(Number, String); moment.duration().subtract(Number); moment.duration().subtract(Duration); moment.duration().subtract(Object); |
|
var duration = moment.duration(x.diff(y)) |
|
moment.duration().as(String); |
|
duration.get( hours ); duration.get( minutes ); duration.get( seconds ); duration.get( milpseconds ); |
|
moment.duration().toJSON(); |
|
moment.isDuration(obj); |
|
moment.duration().toISOString(); |
|
moment.duration().locale(); moment.duration().locale(String); |