ToolBit

ISO 8601 Duration Converter

Convert P1DT2H30M to seconds and plain text

Parts
In words

Type a duration, fill in the parts or enter total seconds

From a date

End date and time

Enter a duration and a start date and time

Runs in your browser. Nothing is uploaded.

Type an ISO 8601 duration such as P1DT2H30M and get the same value as separate parts, as total seconds and as an English phrase. The three inputs are linked: edit any one and the others follow. Designators are case-insensitive, the decimal sign can be a dot or a comma, and a fraction is allowed only on the last part. Errors select the wrong characters.

Normalize rewrites a duration in canonical form. “From a date” adds it to a start date and time in a time zone. Nothing is uploaded.

Example

Duration P1DT2H30M:

Total seconds: 95400
In words:      1 day, 2 hours and 30 minutes

Normalize PT90M and you get PT1H30M; PT3600S becomes PT1H; P14D becomes P2W; PT1.5H becomes PT1H30M.

From 2026-03-07T12:00 in America/New_York, which is the day before clocks go forward:

PT24H  →  2026-03-08T13:00-04:00
P1D    →  2026-03-08T12:00-04:00

Read durations in code

Duration.parse accepts days and time parts only (PnDTnHnMn.nS). Period.parse accepts years, months, weeks and days, with no time part.

import java.time.Duration;
import java.time.Period;

Duration d = Duration.parse("P1DT2H30M");
System.out.println(d.getSeconds()); // 95400
System.out.println(d);              // PT26H30M

Period p = Period.parse("P1Y2M3W4D");
System.out.println(p);              // P1Y2M25D

parseIsoString takes days and time parts, not years, months or weeks.

import kotlin.time.Duration

val d = Duration.parseIsoString("P1DT2H30M")
println(d.inWholeSeconds) // 95400

Temporal is not in every browser yet; check MDN’s compatibility table.

const d = Temporal.Duration.from("P1DT2H30M");
console.log(d.total("seconds")); // 95400

const month = Temporal.Duration.from("P1M");
console.log(
  month.total({
    unit: "days",
    relativeTo: Temporal.PlainDate.from("2026-01-01"),
  }),
); // 31

The datetime documentation describes no duration parser. This pattern handles days and time parts only.

import re
from datetime import timedelta

m = re.fullmatch(r"P(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?", "P1DT2H30M")
d, h, mi, s = (int(g or 0) for g in m.groups())
print(timedelta(days=d, hours=h, minutes=mi, seconds=s).total_seconds())  # 95400.0

time.ParseDuration is not ISO 8601: it reads 26h30m, and hours are its largest unit.

d, err := time.ParseDuration("26h30m")
fmt.Println(d, d.Seconds(), err) // 26h30m0s 95400 <nil>

Limitations

  • With years or months, Total seconds reads “Depends on the start date”, because those have no fixed length.
  • Total seconds counts days as 24 hours. A calendar day across a daylight saving change can be 23 or 25 hours.
  • At most 15 digits per part and 9 decimal places.
  • “From a date” adds years, months and days on the calendar and clamps the day (2026-01-31 + P1M is 2026-02-28). Hours, minutes and seconds are elapsed time. Years run from 0001 to 9999; fractional years or months cannot be added.
  • A leading minus and weeks combined with other parts are accepted, with a note that they are extensions.
  • Not supported: the alternative format P0001-02-03T04:05:06, intervals (start/end) and repeating intervals (R5/...).

FAQ

What do P and T mean in an ISO 8601 duration?

P marks the start of a period. T separates the date parts (years, months, weeks, days) from the time parts (hours, minutes, seconds). P1DT2H is one day and two hours. T must be followed by a time part.

Why are PT1M and P1M different?

M means minutes after T and months before it. PT1M is 60 seconds. P1M is one calendar month, 28 to 31 days.

Why do months and years have no fixed number of seconds?

Their length depends on the start date: one month from 1 January is 31 days, from 1 February 28 or 29. Seconds are exact only with a start date, so enter one under “From a date”.

Can weeks be combined with other parts, like P1Y1W1D?

The basic ISO 8601-1 form keeps weeks separate: P2W, not P1W1D. Java’s Period and JavaScript Temporal.Duration accept combinations, as does this tool, flagged as an extension. Normalize rewrites it as days: P1Y1W1D becomes P1Y8D.

What is the difference between Java Duration and Period?

Duration is a time amount in seconds and nanoseconds; it parses days as exactly 24 hours and never prints days (PT48H, not P2D). Period holds years, months and days that follow the calendar, so P1M added to a date depends on the date.