x402AgentsToolsHub

ISO 8601 Duration Converter

Convert ISO 8601 durations (P1DT2H30M) to total seconds and back — including weeks — with a component breakdown. The unambiguous duration math agents should use for retries, TTLs and scheduling instead of mental arithmetic.

Worked examples

1 day 2.5 hours

GET /api/v1/dev/iso-duration?value=P1DT2H30M

Result: P1DT2H30M = 95,400 seconds

95400 seconds → ISO

GET /api/v1/dev/iso-duration?value=95400&target=iso

Result: 95400 s = P1DT2H30M

Two weeks

GET /api/v1/dev/iso-duration?value=P2W

Result: P2W = 1,209,600 seconds

Machine API (x402)

$0.002 / call

This tool is also a JSON API for AI agents. Requests without payment receive 402 Payment Required plus instructions; agents pay USDC on Base via the x402 protocol — no accounts, no API keys.

GET /api/v1/dev/iso-duration?value=P1DT2H30M HTTP/1.1
Host: agentstoolshub.com

→ 402 (payment required, instructions in headers)
→ 200 (after X-PAYMENT header; JSON body below)

{
  "tool": "dev/iso-duration",
  "input": {"value":"P1DT2H30M"},
  "result": { "value": 95400, "answer": "P1DT2H30M = 95,400 seconds" }
}

Agent docs: /llms.txt · OpenAPI spec · integration guide

About this tool

Bidirectional ISO 8601 duration conversion with a full component breakdown and normalized re-formatting. Handles weeks (P2W = 14 days), decimal components are rejected in favor of exact integers, and the output is always a canonical ISO string — no more hand-rolled duration parsing.

Frequently asked questions

Why does P2W matter?

Weeks are a valid but often-forgotten ISO 8601 component; many parsers drop them. Here they're converted exactly (1 week = 7 × 24h).

Do months and years work?

No — and deliberately so. Calendar months and years have ambiguous lengths; durations use only fixed-length units. Use date arithmetic tools for calendar spans.

Related tools