Duration Formatter
Convert seconds to human-readable duration formats: compact, verbose, colon notation, ISO 8601, and more.
Seconds Input: Formatted Versions: 0
Duration Formatter
APIs and databases often store durations as raw seconds. This tool converts a seconds value into all common human-readable forms: the ISO 8601 Duration format (used by REST APIs and XML Schema), colon notation (HH:MM:SS, common in media players), compact shorthand (2h 30m), and full verbose English. 3,661 seconds = 1 hour, 1 minute, and 1 second.
Built and maintained by Meet Shah · Last updated
What this tool is used for
- Turning a raw seconds count from a log or an API into something a human can read.
- Producing an ISO 8601 duration for a field that requires that format.
- Formatting a video or a task length as colon notation for a UI.
- Converting a long uptime figure into days and hours.
- Comparing two durations expressed in different units.
Frequently Asked Questions
- What is ISO 8601 duration format?
- P[n]Y[n]M[n]DT[n]H[n]M[n]S — so PT1H30M is 90 minutes and P1Y2M is a year and two months. The T separates date from time parts, which is why the M before it means months and after it means minutes.
- Why can't a duration be converted to an exact date offset?
- Because months and years have variable length. P1M added to 31 January is ambiguous, and adding P1Y to 29 February has no exact answer. Only durations in days and below are unambiguous.
- How should durations be stored?
- As a single integer in the smallest unit you need — seconds or milliseconds — not as formatted text. Formatting is a presentation concern; storing '1h 30m' means every consumer has to parse it, usually inconsistently.
- Are days always 24 hours?
- No, and assuming so causes real bugs. Daylight-saving transitions produce 23- and 25-hour days, so adding 86,400 seconds is not the same as adding one calendar day. Date libraries distinguish the two deliberately.
- How should very short and very long durations be displayed?
- By adapting the unit rather than the format: milliseconds for sub-second values, and dropping trailing zero components for long ones. '2h 0m 0s' reads worse than '2h', and both are the same duration.
- Should a duration display seconds?
- Only when the precision is meaningful. "2 hours 14 minutes" reads better than "2h 14m 33s" for anything long, and the seconds imply an accuracy the underlying measurement usually lacks.
- How should a duration be pluralised?
- By value, and languages differ in how many plural forms they have — Polish has three, Arabic six. A format built by concatenating a number and a suffix works in English and breaks elsewhere, which is what `Intl.RelativeTimeFormat` exists for.
Common errors and gotchas
- Confusing seconds with milliseconds, which puts every duration out by a factor of a thousand.
- Assuming a month or a year has a fixed length, which ISO durations deliberately leave calendar-dependent.
- Dropping the leading zero in colon notation, which breaks sorting and alignment.
- Rounding down and losing a partial unit that mattered, such as reporting 59 minutes for 59.9.
- Mixing a verbose form with a colon form in the same list, which makes the values incomparable at a glance.
Related Text Tools tools
Case Converter
Convert between Sentence, Title, camelCase, snake_case, and more.
Word Counter
Count words, characters, and analyze keyword density.
Text to Binary
Convert text into its 8-bit binary representation.
Binary to Text
Decode 8-bit binary back into readable text.
Text Reverser
Reverse text by characters, words, or lines.
Remove Duplicate Lines
Delete repeated lines and keep your list unique.
Remove Empty Lines
Strip blank and whitespace-only lines from text.
Sort Lines Alphabetically
Sort lines A–Z or Z–A, case-sensitive or not.