# ISO 8601 Duration Builder

Convert between natural-language durations and ISO 8601 durations (PnYnMnDTnHnMnS) in both directions with validation of edge cases

> Canonical page: https://elysiatools.com/en/tools/iso-8601-duration-builder

- **Category:** Development

- **Keywords:** iso 8601, duration, interval, pny, time format, converter, natural language, java duration, javascript duration, timedelta

## Overview

Bidirectional converter for ISO 8601 durations. Natural language (e.g. "3 years 2 months 14 days", "2h30m", "3天2小时") parses to canonical P3Y2M14D; ISO strings parse back to readable form with per-component breakdown. Validates the tricky ISO 8601 rules (T-section units, weeks not combined with Y/M/D, decimal only on smallest unit, at least one component).

## Inputs

- **Input** (text): Natural: 3 years 2 months 14 days · 2h30m · 3天2小时 ISO 8601: P3Y2M14D · PT2H30M · P1WT12H
- **Direction** (select)

## When to use

- When writing configuration files, API payloads, or database schemas that require strict ISO 8601 duration formats.
- When parsing and debugging complex ISO 8601 duration strings received from external APIs or system logs.
- When converting user-friendly, natural-language time intervals into standardized machine-readable formats.

## How it works

- Enter a natural-language duration or an ISO 8601 duration string into the input field.
- Select the conversion direction, or leave it on Auto to let the tool detect the input format.
- Review the generated output, which displays the converted format alongside a detailed component breakdown.

## Use cases

- Generating standardized duration strings for system configuration files or environment variables.
- Translating machine-generated ISO 8601 intervals into human-readable text for application dashboards.
- Validating that duration strings comply with strict ISO 8601 standards before saving them to a database.

## Frequently asked questions

### What is the basic format of an ISO 8601 duration?

It follows the pattern PnYnMnDTnHnMnS, where P is the duration designator, Y/M/D represent date units, T is the time designator, and H/M/S represent time units.

### Can I mix weeks with other units in ISO 8601?

No, standard ISO 8601 rules state that weeks (W) should not be combined with other date or time units like years, months, or days.

### Where can decimal fractions be used in a duration string?

Decimals are only permitted on the smallest, final unit present in the duration string, such as PT1.5H or PT1H30.5M.

### What does the 'T' designator signify in the duration string?

The 'T' designator separates date units (Years, Months, Days) from time units (Hours, Minutes, Seconds) to prevent ambiguity between Months (M) and Minutes (M).

### Does this tool support negative durations?

The tool validates standard ISO 8601 duration components and outputs canonical positive intervals based on the input provided.

## Related tools

- [Cron Expression Explainer](https://elysiatools.com/en/tools/cron-expression-explainer): Parse a 5-part / 6-part / Quartz cron expression into a plain-language schedule description, show the field-by-field breakdown, and list the next N execution times in any IANA timezone — with an AI-generated natural-language explanation in your language
- [cURL to Go (net/http) Converter](https://elysiatools.com/en/tools/curl-to-go): Convert a cURL command into a Go net/http code snippet with http.NewRequest, headers, and body
- [cURL to JavaScript (axios) Converter](https://elysiatools.com/en/tools/curl-to-js-axios): Convert a cURL command into a JavaScript axios code snippet with config object, headers, and data
- [cURL to JavaScript (fetch) Converter](https://elysiatools.com/en/tools/curl-to-js-fetch): Convert a cURL command into a JavaScript fetch() code snippet with headers, body, and method
- [cURL to PHP (cURL) Converter](https://elysiatools.com/en/tools/curl-to-php): Convert a cURL command into a PHP cURL code snippet with curl_setopt, headers, and post fields
- [cURL to Python (requests) Converter](https://elysiatools.com/en/tools/curl-to-python): Convert a cURL command into a Python requests code snippet with headers, data, and method
- [HTTP Request Tester](https://elysiatools.com/en/tools/http-request-tester): A lightweight in-browser HTTP client (mini Postman): send GET/POST/PUT/DELETE requests with custom headers and body, inspect status, headers, timing, and formatted response — all from your browser
- [API Contract Stress Tester](https://elysiatools.com/en/tools/api-contract-stress-tester): Generate boundary-value test cases from an OpenAPI 3.x document and optionally send them to a real backend to spot contract mismatches

## Samples

- [Web Image Processing Python Samples](https://elysiatools.com/en/samples/web-image-processing-python): Web Python image processing examples using PIL/Pillow including reading, saving, resizing, and format conversion
- [Android Image Processing Java Samples](https://elysiatools.com/en/samples/android-image-processing-java): Android Java image processing examples including reading/saving images, scaling, and format conversion
- [Android Image Processing Kotlin Samples](https://elysiatools.com/en/samples/android-image-processing-kotlin): Android Kotlin image processing examples including reading/saving images, scaling, and format conversion
- [Web Image Processing Rust Samples](https://elysiatools.com/en/samples/web-image-processing-rust): Web Rust image processing examples including image read/save, scaling, and format conversion
