DevTools Logo

Duration Formatter

Duration Formatter

Turn seconds, milliseconds, ISO-8601 or clock notation into readable durations — and parse them back.

Runs in your browser
Try a duration

Duration

pasted locally

Unit strings, colon clocks, ISO-8601 and scientific notation are all accepted.

Arithmetic & epoch delta

Add or subtract two durations

Elapsed time between two epoch stamps

Formats

awaiting input

Paste a duration to format it

Try 3661.5, 1:02:05 or PT2H30M above.

Examples

Uptime in seconds

Input
3661.5 (bare number, seconds)

Compact output: 1h 1m 01.5s with decimals set to 1; long form: 1 hour, 1 minute, 1.5 seconds.

Latency in milliseconds

Input
5400000 (bare number, milliseconds)

The basis line reads milliseconds and the result is 1h 30m; the dual reading also shows what the same digits would mean in seconds.

ISO-8601 from an API

Input
PT2H30M

Parsed as an ISO-8601 duration and echoed back as PT2H30M, alongside 2 hours, 30 minutes and the clock value 02:30:00.

Log timestamp difference

Input
1:02:05 (colon clock)

Read as 1 hour, 2 minutes, 5 seconds (3725 s), then re-emitted as 01:02:05.

About this tool

The formatter detects five input shapes: a bare number (interpreted as seconds or milliseconds, your choice), scientific notation, a unit string such as 1h 30m or 1500ms, a colon clock such as hh:mm:ss, and a date-less ISO-8601 duration such as PT1H30M or P1DT2H. The parse basis is shown every time, together with both readings of bare numbers, because confusing 300000 seconds with 300000 milliseconds is the most common mistake this tool prevents. Each value is rendered simultaneously in compact log style (1h 32m 05s), long form (1 hour, 32 minutes, 5 seconds), ISO-8601, HH:MM:SS, decimal totals (seconds, minutes, hours, milliseconds) and a remaining/cumulative unit table. Rounding (floor, nearest, ceil) applies at the smallest displayed unit, which you can choose from seconds, milliseconds or microseconds with 0 to 3 decimals. Negative durations keep their sign in every output, including -PT1M30S. You can add or subtract two durations, find the elapsed time between two epoch stamps with explicit units, and paste a whole list for a per-line batch table with CSV or Markdown export. Weeks, months and years are deliberately excluded: their lengths depend on context, so the ladder stops at days. Values above 100,000 days are rejected with an explicit overflow message. Everything runs in your browser — no duration is uploaded.

What this tool does not do

  • Processes only the inputs provided in this session without connecting to external accounts or background servers.
  • Runs entirely in the current browser tab; nothing is synced across devices or backed up to a server.

How to use this tool

  1. Enter a duration in any syntax

    Type seconds, milliseconds, 1h 30m unit strings, HH:MM:SS, or ISO PT1H30M.

  2. Confirm bare-number unit

    Select seconds or milliseconds when entering plain numeric values.

  3. Copy your target representation

    Copy compact, verbose, clock, ISO-8601, or decimal unit equivalents.

Use cases

Uptime in seconds

Compact output: 1h 1m 01.5s with decimals set to 1; long form: 1 hour, 1 minute, 1.5 seconds.

Latency in milliseconds

The basis line reads milliseconds and the result is 1h 30m; the dual reading also shows what the same digits would mean in seconds.

ISO-8601 from an API

Parsed as an ISO-8601 duration and echoed back as PT2H30M, alongside 2 hours, 30 minutes and the clock value 02:30:00.

Log timestamp difference

Read as 1 hour, 2 minutes, 5 seconds (3725 s), then re-emitted as 01:02:05.

Common mistakes

Mistake:What is ISO-8601 PT1H30M duration syntax?

Fix:ISO-8601 durations start with P (period), optional days (D), then T before time components hours (H), minutes (M), and seconds (S)—for example P2DT3H15M for 2 days, 3 hours, 15 minutes.

Mistake:Why does calendar breakdown stop at days instead of months or years?

Fix:Months (28–31 days) and years (365–366 days) depend on specific calendar dates, whereas fixed time durations convert deterministically up to 24-hour days.

Frequently asked questions

How does the parser tell seconds apart from milliseconds?

Explicit suffixes like 90s, 1500ms, or 2h 15m are unambiguous; for bare numbers you select the input unit (seconds or milliseconds) directly so large values are never misread.

What is ISO-8601 PT1H30M duration syntax?

ISO-8601 durations start with P (period), optional days (D), then T before time components hours (H), minutes (M), and seconds (S)—for example P2DT3H15M for 2 days, 3 hours, 15 minutes.

Why does calendar breakdown stop at days instead of months or years?

Months (28–31 days) and years (365–366 days) depend on specific calendar dates, whereas fixed time durations convert deterministically up to 24-hour days.

How are negative durations formatted?

A leading minus sign is preserved consistently across compact, long-form, HH:MM:SS, and ISO-8601 outputs.