- 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 - As ISO 8601 String
This method will return the duration as an ISO 8601 string.
Syntax
moment.duration().toISOString();
Example
var d = moment.duration(2, 'weeks').toISOString();
Output
Note that the P shown in the output above stands for period.
The table given here shows the Format PnYnMnDTnHnMnS description −
Sr.No. | Unit & Description |
---|---|
1 | P P stands for period. Placed at the start of the duration representation. |
2 | Y Year |
3 | M Month |
4 | D Day |
5 | T Designator that precedes the time components. |
6 | H Hour |
7 | M Minute |
8 | S Second |
momentjs_durations.htm
Advertisements