ISO 8601 Duration Parser
Paste an ISO 8601 duration like P1Y2M3DT4H5M6S and instantly see the human-readable breakdown and total seconds, minutes, hours, and days.
Reading an ISO 8601 duration
An ISO 8601 duration always starts with P (for “period”), followed by a number and a letter for each unit you want to include. You only need to include the units that are non-zero:
P1Y— 1 yearP3M— 3 monthsP7D— 7 daysPT1H— 1 hour (note the T before time units)PT30M— 30 minutesPT45S— 45 secondsP1DT12H— 1 day and 12 hoursP1Y2M3DT4H5M6S— the full format
The T in the middle is essential — it disambiguates M (which means months before T and minutes after it). Without T, there is no way to tell whether P1M is 1 month or 1 minute, so the standard uses T as a divider: P1M is 1 month, PT1M is 1 minute. Need the total in a specific numeric unit rather than the ISO string itself? The Duration Unit Converter converts between nanoseconds and weeks directly.
Where you will see these strings
ISO 8601 durations appear wherever a system needs to store or transmit a length of time as text rather than a number. A few common places:
- Google Calendar API — event durations and recurrence rules use ISO 8601 duration strings
- AWS Step Functions —
HeartbeatSecondsand wait-state durations - Kubernetes — timeouts in CRDs and operator configs, e.g.
terminationGracePeriodSecondsexpressed as duration strings in some operators - YouTube Data API — video durations returned as ISO 8601 duration strings
- OpenAPI / JSON Schema — the
durationformat maps to ISO 8601 - iCalendar / VCALENDAR — event and alarm durations in .ics files
Frequently asked questions
What is an ISO 8601 duration?
An ISO 8601 duration is a standard way to represent a length of time as text, like P1Y2M3DT4H5M6S (1 year, 2 months, 3 days, 4 hours, 5 minutes, 6 seconds). It always starts with P (for 'period'), uses capital letters as designators for each unit, and puts T before the time part to separate day-level units from hour-level units.
Where are ISO 8601 durations used?
They appear in many APIs and config formats: Google Calendar API (event durations), AWS Step Functions (wait states), Kubernetes (timeouts and intervals), OpenAPI/Swagger specs, YouTube Data API (video lengths), RSS and Atom feeds, cron-like scheduling DSLs, and XMPP/calendar protocols. If you see a value starting with P in a config file, it is almost certainly an ISO 8601 duration.
What does the T in the middle of the duration mean?
The T separates date-level units (years, months, weeks, days) from time-level units (hours, minutes, seconds). It is required if any time units follow. PT1H means 1 hour; P1D means 1 day. Without T, M would be ambiguous — is it months or minutes? T resolves it: P1M is 1 month, PT1M is 1 minute.
Why are conversions to seconds approximate for years and months?
A year can be 365 or 366 days (leap years). A month can be 28, 29, 30, or 31 days. The ISO 8601 duration standard defines years and months as calendar units — their exact length depends on which specific dates they span. When converting without a reference date, the tool uses 365.25 days per year and 30.44 days per month (the same average used by most calculation tools). The result is accurate to within a day or two for typical durations.
Can a duration be negative?
The ISO 8601 standard does not define negative durations, but many implementations support a leading minus sign (e.g. -P1D). This tool parses the minus prefix and flags the duration as negative. Some systems use negative durations to represent offsets into the past, but check your specific API's documentation to confirm support.
What is the difference between P1D and PT24H?
They represent the same wall-clock length (1 day = 24 hours) for most purposes. The difference matters during DST transitions — adding P1D to a datetime means 'same time tomorrow' (which may be 23 or 25 hours of elapsed time), while adding PT24H always means exactly 24 × 3600 seconds. Calendar libraries account for this distinction; pure arithmetic does not.
Can duration components have decimal values?
Yes — ISO 8601 allows the last (lowest-order) component to be fractional. PT1.5H means 1.5 hours (90 minutes). P0.5D means half a day. In practice, fractional values are uncommon and not all parsers support them, but the tool handles them correctly.