# ISO 8601 Duration Parser & Arithmetic Workbench

Parse ISO 8601 durations, validate ISO 8601-2 extensions, run calendar-true arithmetic, sort by real length at an anchor, and diff datetimes.

> Canonical page: https://elysiatools.com/en/tools/iso-8601-duration-parser-arithmetic-workbench

- **Category:** Date & Time

- **Keywords:** iso 8601, duration, temporal.duration, calendar arithmetic, kubernetes duration, rrule, icalendar duration, time interval

## Overview

A duration calculator, not a format converter. Four modes: parse & inspect, arithmetic expression, sort by real length, and calendar difference between two datetimes.

## Inputs

- **模式** (select)
- **时长 / 表达式** (textarea): P1Y2M3DT4H5M6S P3W PT36H -PT30M P0D (expression mode) P1Y2M + P11M - P90D
- **锚点时刻** (text): 2026-01-15T00:00:00Z (default)
- **起始时刻** (text): 2026-01-01T00:00:00Z (diff mode)
- **结束时刻** (text): 2026-02-15T12:30:00Z (diff mode)

## When to use

- When parsing and validating standard ISO 8601 or ISO 8601-2 duration strings like P1Y2M, PT36H, or P2W3D.
- When evaluating arithmetic expressions like P1Y2M + P11M - P90D against a specific calendar anchor date.
- When calculating the exact ISO duration between two timestamps or sorting multiple durations by elapsed length.

## How it works

- Select your target workbench mode: Parse & Inspect, Arithmetic Expression, Sort by Real Length, or Datetime Difference.
- Enter your ISO 8601 duration strings, mathematical expression, or start and end timestamps into the designated input fields.
- Specify an anchor datetime to anchor variable-length calendar components such as months and leap years.
- Inspect the parsed component breakdown, canonical ISO representation, or step-by-step arithmetic calculation table.

## Use cases

- Validating Temporal.Duration and iCalendar RRULE intervals for scheduling workflows.
- Evaluating subscription rollups and expiration dates across varying calendar month lengths.
- Calculating exact ISO 8601 intervals between start and end events in system audit logs.

## Frequently asked questions

### What duration formats does the workbench support?

It supports standard designators (P1Y2M3DT4H5M6S), week formats (P3W), time-only offsets (PT36H), negative durations (-PT30M), and ISO 8601-2 combined extensions (P2W3D).

### Why is an anchor datetime needed for duration arithmetic?

Calendar units like months and years do not have fixed lengths, so an anchor timestamp is required to compute accurate day offsets across month boundaries and leap years.

### How does expression mode evaluate duration calculations?

It parses additive and subtractive duration terms, applies them sequentially from the anchor datetime, and reconstructs the resulting difference as a normalized ISO duration.

### How does sorting durations work?

It projects each duration from the specified anchor datetime, measures the exact elapsed seconds, and orders the list from shortest to longest.

### What is the difference between parse mode and diff mode?

Parse mode inspects and normalizes existing duration strings, whereas diff mode calculates the ISO 8601 duration between two distinct datetimes.

## Related tools

- [Date Range Validator](https://elysiatools.com/en/tools/date-range-validator): Validate if dates are within a specified range
- [Chess FEN, PGN & Elo Rating Tutor](https://elysiatools.com/en/tools/chess-fen-pgn-elo-rating-tutor): Parse & validate FEN board snapshots, PGN/SAN movetext (with parity, check/mate counts, threefold); compute Elo rating updates from win/draw/loss results, with Lichess/Chess.com tier bands
- [Cron Expression Visualizer](https://elysiatools.com/en/tools/cron-expression-visualizer): Parse cron schedules, validate standard or Quartz syntax, and visualize the next execution times on a timeline and grouped calendar view
- [CSV Malformed Row Surgeon](https://elysiatools.com/en/tools/csv-malformed-row-surgeon): Surgically repair malformed CSV rows one at a time: unescaped (stray) quotes, mixed delimiters (tab/semicolon/comma in the same file), BOM-prefixed headers, CRLF/CR line endings and trailing empty lines. The surgeon parses tolerantly, shows a row-level red/green diff of every change it made (before → after, with the repair reason tagged), lists the rows it accepted unchanged, and emits the cleaned CSV. Optional AI repair can review suspicious rows after the deterministic pass. It complements the CSV Validator (which only reports problems) by actually fixing the damaged rows.
- [Security Headers Checker](https://elysiatools.com/en/tools/security-headers-checker): Audit HTTP response headers for security compliance — parses the raw headers you paste (no network) and grades them against the OWASP secure-header set with value-level checks: HSTS max-age, CSP unsafe-inline/eval, X-Content-Type-Options, Referrer-Policy, Permissions-Policy, COOP/COEP/CORP and more. Outputs a letter grade (A+ to F) plus per-header findings with copy-ready fix recommendations.
- [Date Overlap Checker](https://elysiatools.com/en/tools/date-overlap-checker): Check if date ranges overlap with each other
- [.env Parser](https://elysiatools.com/en/tools/env-parser): Extract and validate .env style KEY=VALUE configurations with detection of duplicate keys and suspicious spaces/quotes
- [Hosts File Editor](https://elysiatools.com/en/tools/hosts-file-editor): Parse, validate, and format hosts file entries

## Samples

- [Nginx Log Parser Samples](https://elysiatools.com/en/samples/nginx-log-samples): Comprehensive Nginx log samples for testing log-parser tool, including access logs and error logs with various formats and scenarios
- [ISO Viewer Samples](https://elysiatools.com/en/samples/iso-viewer-samples): A ISO archive sample for in-browser preview
- [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
