TToolbox
PT1H

ISO 8601 Duration Converter

Convert P1DT2H style durations and seconds

About this tool

The ISO 8601 Duration standard is an international format for expressing time spans using designated designators beginning with the 'P' indicator (e.g., 'P1Y2M10DT2H30M' for 1 year, 2 months, 10 days, 2 hours, and 30 minutes). This tool provides bidirectional conversion between raw ISO duration strings, human-friendly natural language, total seconds, and milliseconds, extensively utilized across AWS Step Functions, Temporal workflows, YouTube Data APIs, and enterprise SLA management.

How to Use This Tool (Step-by-Step)

1

Enter ISO 8601 String or Units

Type a valid duration (e.g., PT1H45M, P7D) or tweak individual year, month, day, hour, and minute counters.

2

Inspect Humanized Breakdown

Instantly view readable phrases (e.g., '1 hour 45 minutes') along with absolute elapsed seconds.

3

Copy Normalized Output

Export normalized strings ready for inclusion into cloud orchestration definitions or database retention policies.

ISO 8601:2004 Strict Syntax

Fully handles both calendar period segments (Y/M/W/D) and time segments delimited by the required 'T' marker.

Raw Seconds Inversion

Reverse-engineers raw numeric seconds (e.g., 3661s) into the most compact canonical ISO representation (PT1H1M1S).

Instant In-Browser Execution

Calculations run client-side with zero external latency, ensuring reliable performance in disconnected development sandboxes.

ISO 8601 Duration Best Practices & Pitfalls

  • •Disambiguating the Letter 'M': In ISO 8601, 'M' before the 'T' designator denotes Months (P2M), whereas 'M' following 'T' denotes Minutes (PT2M). Omitting 'T' causes critical parsing errors.
  • •YouTube Data API Integration: YouTube video metadata returns duration exclusively in ISO 8601 (e.g., 'contentDetails.duration: PT4M13S'), requiring frontend conversion to '04:13' for end-user UIs.
  • •Nominal Calendar Conversions: Because months vary in length (28-31 days) and leap years exist, converting 'P1M' or 'P1Y' into absolute seconds assumes standard averages (1 month = 30 days, 1 year = 365 days) unless anchored to an explicit datetime.

Code & Transformation Examples

ISO Duration to Seconds Mapping

ISO 8601 Duration String
P1DT2H30M15S
Humanized Output & Seconds
1天 2小时 30分钟 15秒 (总计: 95,415 秒)

* Supports seamless aggregation of both calendar days and time elements into total elapsed seconds.

JavaScript Regex Duration to Seconds

Sample Duration Input
PT2H30M
Calculated Elapsed Seconds
9000 秒 (2 * 3600 + 30 * 60)

* Regular expressions can reliably extract hours and minutes for client-side timing arithmetic.

Frequently Asked Questions

Q: What is the purpose of the 'T' designator in ISO 8601 durations?

A: It is required to delimit calendar units from clock time units. The letter 'M' means Months before 'T' and Minutes after 'T'.

Q: What does a trailing 'W' signify in ISO durations?

A: 'W' stands for Weeks. 'P1W' is functionally equivalent to 'P7D'. The specification recommends using weeks independently rather than mixing with months or days.

Q: Why do cloud state machines prefer ISO durations over raw seconds?

A: Because ISO strings are self-documenting. Reading 'PT12H' prevents human calculation blunders compared to parsing raw numbers like 43200 seconds.

Related Tools

All processing happens locally in your browser. Your data is never uploaded to a server.
/