ISO 8601 duration calculator

Check an ISO 8601 duration like P1DT12H or PT36H, see how long it is, and apply it to a date in a time zone. The page shows how P1D and PT24H differ across a daylight saving change, and how a month is added at the end of the month. Nothing you type leaves your browser.

The tool

Parse and check a duration

Try:

Apply it to a date

Direction

How to use

  1. Type a duration in ISO 8601 duration. It starts with P; years, months, weeks and days follow, then T and hours, minutes and seconds. Each part is a number followed by its letter: P3Y6M4DT12H30M5S. The buttons fill in examples.
  2. Read the two verdicts. ISO 8601 follows the standard as published summaries describe it; Temporal follows the format that JavaScript's Temporal.Duration accepts, as MDN documents it. They differ on a few strings (weeks mixed with days, signs, fractions on days). Reasons are shown when a verdict is not valid.
  3. For a valid duration, the page shows its components and, when it has no years or months, its length in seconds. If it has only hours, minutes and seconds, that length is exact. If it has days or weeks, the page labels it "nominal length" because it counts a day as 24 hours, which a calendar day is not across a clock change. With years or months it says "no fixed length".
  4. To apply it to a date, type a Start (YYYY-MM-DD hh:mm:ss), choose the zone and whether to add or subtract. The result shows the new local time with its offset, the instant in UTC, and the elapsed time between start and result.

The date parts (years, months, weeks, days) are applied to the local calendar date first, with a month-end clamped to the last day of the month; the time parts (hours, minutes, seconds) are then applied as elapsed time. That is the order the page's examples use, and it is why P1D and PT24H can differ.

Worked examples

Every result printed here is recomputed by an automated test from the same engine as the tool; the date arithmetic is also checked against Python's datetime and JavaScript's Date in the tests.

Reading a duration

Input: P1DT12H

Result: ISO 8601 valid; Temporal valid. nominal length PT36H (a day counted as 24 h)

Input: P2W

Result: ISO 8601 valid; Temporal valid. nominal length PT336H (a day counted as 24 h)

Input: PT1.5H

Result: ISO 8601 valid; Temporal valid. fixed length PT1H30M

Input: P1M

Result: ISO 8601 valid; Temporal valid. no fixed length (years and months)

Input: P3Y6M4DT12H30M5S

Result: ISO 8601 valid; Temporal valid. no fixed length (years and months)

Input: PT0S

Result: ISO 8601 valid; Temporal valid. fixed length PT0S

Only a duration made of hours, minutes and seconds has a fixed length, such as PT1H30M. When it contains days or weeks, such as P1DT12H or P2W, the page shows a "nominal length", which counts a day as 24 hours and a week as 7 days. That is a convention of this tool, not a property of the duration: Wikipedia's summary of ISO 8601 notes that the number of seconds in a calendar day is ambiguous (it names leap seconds), and applied to a date in a zone with clock changes a calendar day may be 23 or 25 hours, as the next examples show. Years and months have no fixed length at all.

A day is not 24 hours: P1D versus PT24H

New York's clocks go forward on 7 to 8 March 2026 and back on 31 October to 1 November (the 2026 autumn change is at 02:00 on 1 November).

Start 2026-03-07 12:00:00, America/New_York

Input: P1D

Output: 2026-03-08T12:00:00-04:00; elapsed PT23H

Start 2026-03-07 12:00:00, America/New_York

Input: PT24H

Output: 2026-03-08T13:00:00-04:00; elapsed PT24H

One calendar day later is noon again, but only 23 hours have passed. Twenty-four hours later is 13:00.

Start 2026-10-31 12:00:00, America/New_York

Input: P1D

Output: 2026-11-01T12:00:00-05:00; elapsed PT25H

Start 2026-10-31 12:00:00, America/New_York

Input: PT24H

Output: 2026-11-01T11:00:00-05:00; elapsed PT24H

In the autumn, one calendar day is 25 hours, and 24 elapsed hours end at 11:00.

PT36H versus P1DT12H

Start 2026-03-07 12:00:00, America/New_York

Input: P1DT12H

Output: 2026-03-09T00:00:00-04:00; elapsed PT35H

Start 2026-03-07 12:00:00, America/New_York

Input: PT36H

Output: 2026-03-09T01:00:00-04:00; elapsed PT36H

Months at the end of the month

Start 2026-01-31 09:00:00, UTC

Input: P1M

Output: 2026-02-28T09:00:00+00:00; elapsed PT672H

Start 2028-01-31 09:00:00, UTC

Input: P1M

Output: 2028-02-29T09:00:00+00:00; elapsed PT696H

Start 2028-02-29 09:00:00, UTC

Input: P1Y

Output: 2029-02-28T09:00:00+00:00; elapsed PT8760H

Start 2026-03-31 12:00:00, UTC, subtract

Input: P1M

Output: 2026-02-28T12:00:00+00:00; elapsed PT744H

The elapsed time is different each time (672, 696 and 744 hours), which is why a month has no fixed length. Adding then subtracting a month does not always return to the start: 31 January plus P1M is 28 February, and 28 February minus P1M is 28 January.

A month that lands in a clock gap

Start 2026-02-08 02:30:00, America/New_York

Input: P1M

Output: 2026-03-08T03:30:00-04:00; elapsed PT672H

8 February 02:30 plus one month would be 02:30 on 8 March, which does not exist in New York. The tool uses the same rule as the time zone converter (default: shift later), giving 03:30.

What goes wrong

Invalid or surprising durations. Each result is the tool's exact output.

Missing pieces

Input: P

Result: ISO 8601 not valid; Temporal not valid. A duration needs at least one component with a number: "P" alone and "PT" alone are not valid. Zero is written PT0S or P0D.

Input: P1DT

Result: ISO 8601 not valid; Temporal not valid. The T designator must be followed by at least one time component (hours, minutes or seconds): "P1DT" is not valid.

Input: 1D

Result: ISO 8601 not valid; Temporal not valid. A duration starts with the letter P (for "period").

Letters in the wrong place

Input: P1H

Result: ISO 8601 not valid; Temporal not valid. Hours, minutes and seconds must come after the T designator: write PT1H, not P1H.

Input: P1M1Y

Result: ISO 8601 not valid; Temporal not valid. The components are out of order or repeated. The order is P[n]Y[n]M[n]W[n]D T [n]H[n]M[n]S, each at most once.

A typical slip is P1H for "one hour": the hours, minutes and seconds designators belong after the T. The same applies to M, which is months before the T and minutes after it, so P5M is five months and PT5M is five minutes. Wikipedia's summary of ISO 8601 uses the same P1M and PT1M pair to explain the T.

Where the standard and the libraries differ

Input: P1W2D

Verdicts: ISO 8601 not valid; Temporal valid. nominal length PT216H (a day counted as 24 h)

Input: -P1D

Verdicts: ISO 8601 not valid; Temporal valid. nominal length -PT24H (a day counted as 24 h)

Input: P1.5D

Verdicts: ISO 8601 valid; Temporal not valid. length not converted (fraction on a date unit)

Input: PT1.5H30M

Verdicts: ISO 8601 not valid; Temporal not valid. Only the smallest (last) component may have a decimal fraction, and here a smaller component follows. Write PT1.5H or PT1H30M, not PT1.5H30M.

Input: P1.5DT2H

Verdicts: ISO 8601 not valid; Temporal not valid. Only the smallest (last) component may have a decimal fraction, and here a smaller component follows. Write PT1.5H or PT1H30M, not PT1.5H30M.

Input: PT1,5H

Verdicts: ISO 8601 valid; Temporal valid. fixed length PT1H30M

A decimal fraction is allowed only on the smallest component that is present (Wikipedia's summary: "the smallest value used may also have a decimal fraction"), written with a full stop or a comma. That is why PT1.5H and PT1,5H are valid and PT1.5H30M is not. A string that fails this rule gets no length, components or date result from the tool, only the reason.

If a duration comes from a system you do not control, check which parser reads it: the same text can be accepted by one library and refused by another.

Storing 24 hours when you meant "a day"

"Repeat every day" and "repeat every 24 hours" are different instructions in a zone with daylight saving. See the first pair of examples: after one of each, one lands at noon and the other at 13:00.

Limits & gotchas

  • ISO 8601 was not read. The standard is sold, not published free. The ISO verdict follows the summary of the standard on Wikipedia and the documentation of java.time.Period. Where editions or extensions differ (for example, signed durations in ISO 8601-2), the page says what it did.
  • The Temporal verdict is from MDN's description, not from running Temporal: it was not available in the JavaScript used for testing the site.
  • How a duration is applied to a date is a choice of this tool, not part of ISO 8601: date units on the local calendar first (months clamped to the last day), then time units as elapsed time. Libraries differ in details; the examples show what this tool does.
  • Years, months and weeks. A week is 7 days and a day is a calendar day when it is applied to a date; the "nominal length" line counts a day as 24 hours, which is a convention of this tool and not what the cited sources define; only durations with hours, minutes and seconds alone get a "fixed length".
  • Fractions. A fraction on the smallest time component is converted exactly to nanoseconds, up to 9 digits. A fraction on days, weeks, months or years is valid ISO 8601 but the page cannot apply it to a date and says so.
  • Zone data comes from your browser, so a recent rule change may be missing (see the time zone converter).
  • Repeating intervals and time intervals (R5/.../P1D) are not handled.

FAQ

What does PT36H mean, and how is it different from P1DT12H?

PT36H is 36 elapsed hours. P1DT12H is one calendar day plus 12 hours. They are the same length on a day without a clock change and differ across one: added to noon on 7 March 2026 in New York, P1DT12H lands at 00:00 on 9 March (35 hours later, because the clocks went forward) and PT36H lands at 01:00 (exactly 36 hours later). Wikipedia's summary of ISO 8601 makes the same point about PT36H and P1DT12H.

How long is P1M, or P1Y?

It has no fixed length: a month is 28 to 31 days and a year is 365 or 366. The page shows "no fixed length" for any duration with years or months. Applied to a date, P1M means "the same day of the next month"; when that day does not exist the tool clamps to the last day of the month (31 January plus P1M is 28 February 2026, and 29 February 2028 in a leap year). ISO 8601 does not say how to apply a duration to a date, so this is a stated choice of this tool.

Is P1W2D a valid duration?

Not in ISO 8601-1 as Wikipedia describes it: weeks have a format of their own (PnW) and cannot be combined with days, months or years. Java's Period.parse is more lenient and accepts a mixture (multiplying the weeks by 7), and the string format MDN documents for Temporal.Duration lists weeks and days as separate components of one string, which is how this page reads it. The page shows both verdicts so you can see where a library and the standard differ.

Can a duration be negative or fractional?

A leading minus sign is accepted by java.time and Temporal but is not part of ISO 8601-1 (it belongs to extensions in ISO 8601-2). A decimal fraction is allowed in ISO 8601 on the smallest component only, written with a full stop or a comma, so PT1.5H and PT1,5H are valid while PT1.5H30M, P1.5DT2H and P0.5Y1M are not. Temporal restricts it further: a fraction is allowed only on hours, minutes or seconds, so P1.5D is valid ISO 8601 but not valid for Temporal.

What is the shortest way to write zero?

PT0S or P0D. "P" on its own and "PT" on its own are not valid: at least one component with a number is required.

Sources

  • Wikipedia: ISO 8601 Used for: Calendar, ordinal and week dates; week 1 is the week with the year's first Thursday; the zero offset is written Z or +00:00 (not -00:00); 24:00 was allowed until the 2004 edition, removed in ISO 8601-1:2019 and reintroduced by Amendment 1 (2022); duration syntax PnYnMnDTnHnMnS, "P" alone is invalid, PT0S and P0D are valid, a fraction only on the smallest component, weeks as PnW, and that PT36H and P1DT12H are different durations across a DST change. ISO 8601 itself is sold, not free; it was not read.
  • MDN Web Docs: Temporal.Duration Used for: The Temporal duration string format: optional sign, P, years, months, weeks, days, T, hours, minutes, seconds; letters may be lower case; only the last component may be fractional and only a time unit. This page lists that as the Temporal rule; it was read, not executed, because Temporal is not available in the Node used for the tests.
  • Oracle: Java SE 21: java.time.Period.parse Used for: Period.parse is based on the ISO-8601 PnYnMnD and PnW forms; the leading sign and negative component values are not part of ISO-8601, and ISO-8601 does not permit mixing PnYnMnD with PnW, although java.time itself accepts a mixed string such as P1Y2M3W4D and multiplies the weeks by 7.
  • Oracle: Java SE 21: java.time.ZonedDateTime Used for: For a local date-time that falls in a gap, the zoned date-time is shifted forward by the length of the gap, ending in the later offset; for an overlap the previous offset is retained if there is one, otherwise the earlier offset is used. plusDays works on the local time-line (adding days to the local date-time and converting back), whereas plusHours works on the instant time-line, so adding one hour is always a duration of one hour. Java is not installed on the machine used to build this site, so Java behaviour here is described from the documentation, not executed.
  • MDN Web Docs: Date Used for: The supported range (April 20, 271821 BC to September 13, 275760 AD, plus or minus 100,000,000 days); that Date ignores leap seconds; Number.MAX_SAFE_INTEGER is 9,007,199,254,740,991; the date-time string format (a simplification of ISO 8601, 24:00:00 allowed, expanded years of + or - followed by six digits, -000000 disallowed); and that setting a local time inside a DST transition follows the Temporal "compatible" disambiguation: if the local time corresponds to two instants the earlier one is chosen, and if it does not exist the result goes forward by the gap duration (with the New York 2024 example).
  • Python Software Foundation: datetime: Basic date and time types Used for: datetime.fold: "Used to disambiguate wall times during a repeated interval"; the values 0 and 1 mean the earlier and later of the two moments.
  • IANA: Theory and pragmatics of the tz code and data Used for: The database records the history and the predicted future of civil time scales; names have the form Area/Location (for example Asia/Calcutta was renamed Asia/Kolkata, with the old name kept as a link); the abbreviation list shows that one abbreviation can mean different things (IST appears for India, for Irish time and for Israel).

Every document above was opened and read on 2026-10-03. Documentation changes; if a page here disagrees with the current docs, trust the docs and tell us.