ZenovayTools

Duration Calculator

Convert time durations between seconds, minutes, hours, days, and weeks. Parse human-readable durations like "2h 30m", format milliseconds, and generate ISO 8601 duration strings.

Duration Breakdown

Weeks

0

Days

0

Hours

2

Minutes

30

Seconds

15

Millisec

0

All Formats

Human readable

2h 30m 15s

ISO 8601

PT2H30M15S

HH:MM:SS

2:30:15

Total seconds

9015

Total milliseconds

9015000

Total minutes

150.2500

Total hours

2.504167

Total days

0.10434028

How to Use Duration Calculator

  1. 1Enter a duration as seconds, milliseconds, or in human format (e.g., 2h 30m 15s).
  2. 2View the duration converted to all time units: seconds, minutes, hours, days, weeks.
  3. 3Copy the ISO 8601 duration string or human-readable format for use in your code.
Zenovay

Track your website performance

Real-time analytics, session replay, heatmaps, and AI insights. 2-minute setup, privacy-first.

Try Zenovay Analytics — Free

Frequently Asked Questions

What is ISO 8601 duration format?
ISO 8601 duration format uses the pattern PnYnMnDTnHnMnS, where P is the designator (Period), T separates date from time parts. Examples: PT30S = 30 seconds, PT5M30S = 5 minutes 30 seconds, PT2H = 2 hours, P1DT12H = 1 day 12 hours, P1Y2M3DT4H5M6S = 1 year 2 months 3 days 4 hours 5 minutes 6 seconds. Used in: HTML5 <time datetime="PT1H30M">, XML Schema, REST APIs (Google Calendar, Stripe), RFC 3339 durations, JavaScript Temporal API.
How do I convert milliseconds to human-readable duration?
Divide and take remainders. Given milliseconds ms: days = Math.floor(ms / 86400000), hours = Math.floor((ms % 86400000) / 3600000), minutes = Math.floor((ms % 3600000) / 60000), seconds = Math.floor((ms % 60000) / 1000), remainder_ms = ms % 1000. JavaScript: formatDuration = new Intl.DurationFormat("en", {style: "long"}).format({hours, minutes, seconds}) — part of the Intl.DurationFormat API (Stage 3 proposal). Alternative: dayjs.duration(ms).humanize() or date-fns formatDuration().
How are durations stored in databases?
Options: Integer (seconds or milliseconds) — simplest, easy arithmetic, no timezone issues. PostgreSQL INTERVAL type: INTERVAL '2 hours 30 minutes' — supports arithmetic (+, -), functions EXTRACT(), JUSTIFY_HOURS(). MySQL TIME type: -838:59:59 to 838:59:59 — good for short durations, bad for very long ones. ISO 8601 string: VARCHAR — human-readable but requires parsing for arithmetic. For analytics: store as integer seconds/milliseconds and format for display in the application layer.
What is the difference between duration and interval?
Duration: a fixed amount of time, independent of any reference point. "2 hours" is always 7,200 seconds. Interval: the time between two specific points — affected by DST, leap seconds, and calendar irregularities. Adding "1 month" to Jan 31 gives Feb 28 (or 29), not a fixed number of days. In code: use Duration for things like timeouts, delays, animation timing. Use Interval (two datetimes) for calendar events, billing periods, or any relative-to-calendar calculation. ISO 8601 covers both: PT2H (duration) vs 2024-01-01/2024-12-31 (interval).
How do I calculate elapsed time in JavaScript?
Performance API (most accurate): const start = performance.now(); ... const elapsed = performance.now() - start; — returns milliseconds with sub-millisecond precision, not affected by system clock changes. Date.now(): const start = Date.now(); — milliseconds since Unix epoch, can jump if system time changes. console.time/timeEnd: console.time("label"); ... console.timeEnd("label"); — built-in for quick measurements. For very long processes (hours/days): store ISO 8601 timestamps to a database and subtract on retrieval.