ForHosting KIT · Developer Utilities

ISO 8601 duration to seconds converter

Turn an ISO 8601 duration such as P3DT4H30M into one total number of seconds. The converter reads years, months, weeks, days, hours, minutes, and seconds, then applies explicit nominal lengths: every year is 365 days and every month is 30 days.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

Because it uses the duration text alone and never consults a calendar, time zone, current date, or daylight-saving rule, the same input always produces the same output. That makes it useful for validation, storage estimates, test fixtures, and systems that need predictable arithmetic.

Read the ISO 8601 duration structure

An ISO 8601 duration begins with the letter P, followed by date units and, when needed, a T separator before time units. For example, P2W means two weeks, P3DT6H means three days and six hours, and PT15M means fifteen minutes. The letter M has two meanings depending on its position: before T it represents months, while after T it represents minutes. This converter recognizes years, months, weeks, days, hours, minutes, and seconds in their standard order. It also accepts a decimal fraction on the smallest unit present, using either a period or comma as the decimal separator. Enter the complete duration in the duration field without surrounding commentary. The result repeats the normalized input, lists every parsed component, and reports total_seconds, making the calculation easy to inspect or pass to another program. Empty durations, reordered designators, negative values, bare P or PT markers, and unrelated text are rejected instead of being guessed. That strict behavior helps detect malformed data at an integration boundary rather than silently turning it into a misleading number.

Understand nominal years and months

A duration containing only days, hours, minutes, or seconds has an unambiguous fixed length. Calendar years and months are different: a real month may contain 28, 29, 30, or 31 days, and a real year may contain 365 or 366. A duration string by itself does not include the starting date needed to resolve those differences. This tool therefore uses nominal constants that are visible in every response: 365 days per year and 30 days per month. Weeks always contain seven days, days contain 86,400 seconds, hours contain 3,600 seconds, and minutes contain 60 seconds. The calculation is a weighted sum of the parsed components. For example, a month contributes 2,592,000 seconds regardless of when the conversion runs. These assumptions are intentional rather than claims about a particular calendar interval. If you need elapsed seconds between two actual timestamps, use a date-time difference operation with explicit endpoints instead. Choosing nominal values here keeps results reproducible across servers, browsers, time zones, leap years, and daylight-saving transitions.

Use deterministic totals safely

The returned total is a whole JSON number of seconds. Fractional ISO values are supported only when the arithmetic resolves to a whole second and the fraction belongs to the smallest unit written, following the duration notation's ordering rule. Thus PT0.5M becomes 30 seconds, while a value that would require a fractional second is rejected. The tool also rejects totals outside JavaScript's safe-integer range, preventing a large duration from appearing precise when it is not. This makes the output suitable for database fields, queue delay validation, timeout configuration, billing simulations, and repeatable tests, provided those systems share the stated nominal calendar assumptions. Preserve the assumptions object with the result when another team might otherwise interpret months as calendar-aware. For automation, the API costs $0.002 per request; the same pure conversion can run in the browser for interactive checks. No network lookup, current clock, random value, or Date object participates in the answer. Given identical input text, the parsed components and total seconds remain identical, which is especially valuable in snapshots and cross-environment comparisons.

Normalize API durations

Convert incoming ISO 8601 duration fields to one integer unit before validation, comparison, or storage.

Build repeatable test fixtures

Generate stable expected second totals without depending on a starting date, local time zone, or current calendar.

Review configuration values

Inspect retention periods, delays, and timeouts supplied in ISO notation and expose the nominal assumptions beside the total.

How long is a year in this converter?

Every year is exactly 365 days, or 31,536,000 seconds.

How long is a month?

Every month is nominally 30 days, or 2,592,000 seconds; no starting calendar date is used.

Does M mean months or minutes?

M before the T separator means months. M after T means minutes.

Are decimal durations accepted?

Yes, on the smallest unit present, when the final result is a safe whole number of seconds. A period or comma may separate the fraction.

What does the API cost?

Each API request costs $0.002. Interactive conversion can also run locally in the browser.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/date/iso-duration-to-seconds

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/date/iso-duration-to-seconds \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"duration":"P1Y2M3DT4H5M6S"}'
{
  "duration": "P1Y2M3DT4H5M6S"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "date.iso_duration_to_seconds",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_chars200
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →