Duration to ISO 8601 format

For developers and anyone filling in XML, schema.org or API fields that expect an ISO 8601 duration.

Loading the tool…

Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.

How to use it

  1. Enter years, months, days, hours, minutes and seconds.
  2. The result appears straight away and updates as you edit.
  3. Copy the result, or copy a link that keeps the same values to share it.

How it is calculated

Write P, then years Y, months M and days D, then T, then hours H, minutes M and seconds S, leaving out zero parts. A zero duration is PT0S.

Example

Inputs: Years = 0, Months = 0, Days = 1, Hours = 2, Minutes = 30. Result: ISO 8601 duration: P1DT2H30M; Total seconds: 95,400.

Limits and caveats

  • Carrying stops at hours and does not roll them into days, since a calendar day is not always 24 hours.
  • Weeks (W) are not used here; enter them as days.

Questions about this tool

How do I write 1.5 hours in ISO 8601?

PT1H30M. PT1.5H and PT90M are also valid.

Why does a zero duration show PT0S?

The standard needs at least one component, and PT0S is the usual way to write zero.

Is P1Y always 365 days?

No, a leap year has 366 days, so no total in seconds is given when years or months are set.