Parse ISO 8601 duration / time interval string
ISO 8601 durations (intervals) represent a span of time independent of any start or end point.
A duration string begins with P (for "period") and lists date components before T
and time components after it. Use this tool to calculate total seconds or to find the date and time a duration ago or from now.
Format: P[nY][nM][nW][nD]T[nH][nM][nS] See below
Examples: PT90S, P1DT12H, P1Y2M3DT4H5M6S or P2W
Enter an ISO 8601 duration string:
Convert seconds to ISO 8601 duration
Enter a number of seconds:
Duration markers
| Marker/Label | Meaning | Example |
|---|---|---|
P | Duration marker (required prefix) | P… |
Y | Years | P2Y — 2 years |
M (before T) | Months | P3M — 3 months |
W | Weeks | P2W — 2 weeks |
D | Days | P10D — 10 days |
T | Time separator (required before H, M, S) | PT… |
H | Hours | PT6H — 6 hours |
M (after T) | Minutes | PT30M — 30 minutes |
S | Seconds (decimal fractions allowed) | PT90S — 90 seconds |
Years and months have variable lengths, so conversions involving them use calendar averages (1 year = 365.2425 days, 1 month = 30.436875 days). The W designator for weeks may not be combined with date designators (D, M, Y) in strict ISO 8601, but this tool accepts mixed forms as commonly seen in practice.
ISO 8601 durations are widely used in APIs, XML schemas (xs:duration), iCalendar (RFC 5545),
and database types such as PostgreSQL interval and Java’s Duration/Period.