Duration parser and formatter

Turn a duration such as "1h 30m", "PT1H30M" or "1:30:00" into seconds, ISO 8601 and plain words.

Input

A duration in words, ISO 8601 or clock form, or a number of seconds to format.

Result

Fill in the input and press Run.

Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.

Use it from code or an agent

curl -s https://setget.net/v1/tools/duration-parse \
  -H 'Content-Type: application/json' \
  -d '{"input":{"value":"1h 30m"}}'
import json, urllib.request

body = {'input': {'value': '1h 30m'}}
request = urllib.request.Request("https://setget.net/v1/tools/duration-parse", json.dumps(body).encode(),
                                 {"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/duration-parse", {
  method: "POST",
  headers: {"Content-Type": "application/json"},
  body: JSON.stringify({"input":{"value":"1h 30m"}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
  "slug": "duration-parse",
  "input": {
    "value": "1h 30m"
  }
}
{
  "input": {
    "value": "1h 30m"
  }
}

Endpoint: POST /v1/tools/duration-parse. Over MCP: run_tool with slug: "duration-parse". Machine-readable: input schema, Markdown. Connect an agent.

Inputs

NameTypeRequiredWhat it does
value string yes A duration in words, ISO 8601 or clock form, or a number of seconds to format.

Examples

Input
{
  "value": "1h 30m"
}
Result
{
  "seconds": 5400,
  "milliseconds": 5400000,
  "iso": "PT1H30M",
  "human": "1 hour and 30 minutes",
  "clock": "1:30:00",
  "parts": {
    "days": 0,
    "hours": 1,
    "minutes": 30,
    "seconds": 0
  }
}

Seconds back to a readable duration

Input
{
  "value": "187200"
}
Result
{
  "seconds": 187200,
  "milliseconds": 187200000,
  "iso": "P2DT4H",
  "human": "2 days and 4 hours",
  "clock": "52:00:00",
  "parts": {
    "days": 2,
    "hours": 4,
    "minutes": 0,
    "seconds": 0
  }
}

Questions

Is 1:30 an hour and a half or a minute and a half?
Two parts are read as minutes:seconds, so 1:30 is 90 seconds. Write 1:30:00 for an hour and a half.
Why are months and years rejected?
They vary in length (28 to 31 days, 365 or 366 days), so they have no exact number of seconds. Use date-add or date-diff when the calendar matters.
How precise is it?
To the millisecond. Smaller fractions are rounded.