Key Facts
- Category
- Developer & Web
- Input Types
- text, select
- Output Type
- html
- Sample Coverage
- 4
- API Ready
- Yes
Overview
The ISO 8601 Duration Builder is a bidirectional converter that translates between natural-language durations and canonical ISO 8601 duration strings. It validates complex formatting rules, including T-section separators, decimal placements, and component combinations, while providing a detailed breakdown of each time unit.
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
Examples
1. Convert Natural Language to ISO 8601
Backend Developer- Background
- A developer needs to store a user-defined trial period of '3 months and 10 days' in a database that requires ISO 8601 format.
- Problem
- Manually formatting the duration string risks syntax errors, especially with the P and T designators.
- How to Use
- Type '3 months 10 days' into the input field and set the direction to 'Natural language → ISO 8601'.
- Example Config
-
Input: '3 months 10 days', Direction: 'nl2iso' - Outcome
- The tool outputs the canonical ISO 8601 duration string 'P3M10D' along with a breakdown of the components.
2. Parse ISO 8601 Duration to Human-Readable Text
Product Manager- Background
- A product manager is reviewing API logs containing duration values like 'PT4H30M' and needs to quickly verify the exact time interval.
- Problem
- Reading raw ISO 8601 strings can be slow and error-prone when scanning multiple logs.
- How to Use
- Paste 'PT4H30M' into the input field and set the direction to 'ISO 8601 → Natural language'.
- Example Config
-
Input: 'PT4H30M', Direction: 'iso2nl' - Outcome
- The tool displays the human-readable translation '4 hours 30 minutes' alongside its individual components.
Try with Samples
developmentRelated Hubs
FAQ
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.