- 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
MomentJS - Months
This method will give no of months in a duration. It will return value from 0-11. To get the length of months in a given duration use moment.duration().asMonths();
Syntax
moment.duration().months(); moment.duration().asMonths();
Example
var m = moment.duration(100, "months").months(); var asmins = moment.duration(500, "months").asMonths();
Output
Years
This method will give no of years.moment.duration().asYears()gets the length of the duration in years.
Syntax
moment.duration().years(); moment.duration().asYears();
Example
var m = moment.duration(500, "years").years(); var asmins = moment.duration(500, "years").asYears();
Output
momentjs_durations.htm
Advertisements
To Continue Learning Please Login
Login with Google