What an ISO-8601 duration looks like
ISO-8601 represents a span of time as a string that begins with P for period.
Date components come first as nY years, nM months, nW weeks, and nD days,
followed by a T and the time components nH hours, nM minutes, and nS
seconds. The same letter M means months before the T and minutes after it,
which is the most common point of confusion. This tool parses the whole string
and reports both totals and a per-component breakdown.
How it works
The parser matches the canonical grammar with a single regular expression,
extracting each optional component and rejecting strings that do not fit, such as
a trailing T with no time parts. It accepts decimal fractions written with a
dot or a comma, so PT1,5H and PT1.5H are equivalent.
To compute a single total, the components are summed into seconds. Days, hours, minutes, and seconds are exact. Years and months have no fixed length, so the tool uses Gregorian mean values: a year is 365.2425 days and a month is one twelfth of a year. Weeks are exactly 7 days.
P1Y2M10DT2H30M -> about 37,090,800 seconds
PT45M -> 2,700 seconds
P2W -> 1,209,600 seconds
Example and notes
Use the component breakdown to verify intent before relying on the totals. If your duration contains only days and smaller units the totals are exact to the second. If it contains years or months, treat the seconds, minutes, and hours totals as averages, since a calendar year that includes a leap day is slightly longer than one that does not. For exact calendar arithmetic, add the duration to a specific start date rather than converting it to a fixed number of seconds.