MomentJS - As ISO 8601 String


Advertisements

This method will return the duration as an ISO 8601 string.

Syntax

moment.duration().toISOString();

Example

var d = moment.duration(2, 'weeks').toISOString();

Output

Strings

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