Stopwatch

Online stopwatch with start, pause, reset controls and lap time tracking.

Back to all tools on ToolForge

More in Date & Time

00:00:00.0

Lap Times

# Lap Time Total Time

About Stopwatch

This online stopwatch provides precise elapsed time measurement with start, pause, reset, and lap recording functionality. It uses JavaScript's high-resolution timestamps (Date.now()) for accurate time tracking, updating the display every 100 milliseconds.

The stopwatch continues tracking accurately even when the browser tab is in the background, as it calculates elapsed time from stored timestamps rather than counting timer intervals. This makes it suitable for long-duration timing tasks.

Stopwatch Display Format

The display shows time in HH:MM:SS.d format (hours, minutes, seconds, tenths of seconds):

Format: HH:MM:SS.d
  HH = Hours (00-99)
  MM = Minutes (00-59)
  SS = Seconds (00-59)
  d  = Deciseconds (tenths of seconds, 0-9)

Examples:
  00:00:00.0 = Start (zero elapsed time)
  00:01:30.5 = 1 minute, 30.5 seconds
  01:00:00.0 = Exactly 1 hour
  02:45:30.0 = 2 hours, 45 minutes, 30 seconds

Stopwatch Algorithm Implementation

This stopwatch uses timestamp-based timing rather than interval counting for accuracy:

// Stopwatch uses Date.now() timestamps for accuracy

let startTime = 0;      // Timestamp when started
let elapsed = 0;        // Accumulated elapsed time (ms)
let timerId = null;     // setInterval reference
let laps = [];          // Lap times array

function start() {
  if (timerId) return;  // Already running
  startTime = Date.now();
  timerId = setInterval(updateDisplay, 100);
}

function pause() {
  if (!timerId) return;
  clearInterval(timerId);
  elapsed += Date.now() - startTime;  // Accumulate elapsed
  timerId = null;
}

function reset() {
  pause();
  elapsed = 0;
  laps = [];
  updateDisplay();
}

function updateDisplay() {
  const total = elapsed + (timerId ? Date.now() - startTime : 0);
  const h = Math.floor(total / 3600000);
  const m = Math.floor((total % 3600000) / 60000);
  const s = Math.floor((total % 60000) / 1000);
  const d = Math.floor((total % 1000) / 100);
  display.textContent =
    String(h).padStart(2, '0') + ':' +
    String(m).padStart(2, '0') + ':' +
    String(s).padStart(2, '0') + '.' + d;
}

function recordLap() {
  const currentTotal = elapsed + (timerId ? Date.now() - startTime : 0);
  const lastLapTotal = laps.length > 0 ? laps[laps.length - 1].total : 0;
  laps.push({
    lap: laps.length + 1,
    time: currentTotal - lastLapTotal,  // This lap duration
    total: currentTotal
  });
  renderLaps();
}

Browser Timer Accuracy Comparison

Browser Foreground Timer Background Timer Notes
Chrome (Desktop) ~4ms minimum Throttled to 1000ms Uses V8 timer throttling
Firefox (Desktop) ~4ms minimum Throttled to 1000ms Similar throttling to Chrome
Safari (macOS/iOS) ~4ms minimum Aggressive throttling Battery optimization
Edge (Chromium) ~4ms minimum Throttled to 1000ms Same as Chrome (Chromium)
Mobile Browsers ~4-10ms Very aggressive Battery saving priority

Why Timestamp-Based Timing is More Accurate

Many simple stopwatches use setInterval alone to count elapsed time, but this approach accumulates errors:

Interval-Based (Less Accurate):
  let count = 0;
  setInterval(() => { count += 100; }, 100);
  // Problem: Browser may delay callbacks
  // After 10 seconds real time, count might be 9500 or 10500

Timestamp-Based (More Accurate):
  const start = Date.now();
  setInterval(() => {
    const elapsed = Date.now() - start;
    // Always shows correct elapsed time
    // Display may lag, but calculation is accurate
  }, 100);

Common Stopwatch Use Cases

Domain Use Case Typical Duration
Fitness Interval training, lap times 30 sec - 2 hours
Cooking Recipe timing, multiple dishes 1 min - 3 hours
Presentations Speech timing, Q&A tracking 5 min - 1 hour
Development Performance testing, benchmarks 100ms - 30 min
Science Experiment duration, reactions 1 sec - 24 hours
Gaming Speedruns, challenge timers 1 min - 10 hours

Time Format Reference

Unit Milliseconds Symbol Example
Millisecond 1 ms ms 100 ms = 0.1 sec
Second 1,000 ms s 60 s = 1 min
Minute 60,000 ms m 60 m = 1 hour
Hour 3,600,000 ms h 24 h = 1 day

Stopwatch vs Timer: When to Use Each

Feature Stopwatch Timer/Countdown
Direction Counts UP from 0 Counts DOWN to 0
Use Case Measure elapsed time Track until deadline
End Condition Manual stop Alarm at zero
Example How long did this take? When will this finish?

Frequently Asked Questions

How accurate is this online stopwatch?
This stopwatch uses JavaScript's Date.now() for timestamp tracking, which provides millisecond precision. The display updates every 100ms via setInterval. Actual accuracy depends on browser timer throttling: Chrome/Firefox limit timers to 4ms minimum, background tabs may throttle to 1000ms. For most timing tasks, accuracy is within ±10-50ms.
What is the difference between stopwatch and timer?
A stopwatch counts UP from zero to measure elapsed time (useful for workouts, experiments, response time). A timer counts DOWN from a set time to zero (useful for cooking, Pomodoro, countdowns). This tool is a stopwatch for measuring duration, not a countdown timer.
Does the stopwatch work in background tabs?
The stopwatch continues tracking time accurately in background tabs because it uses Date.now() timestamps rather than counting intervals. However, the display updates may be throttled by browsers to save battery. When you return to the tab, the displayed time will jump to the correct elapsed time.
What is lap time and how is it different from split time?
Lap time shows the duration for each individual segment (lap 1: 0:30, lap 2: 0:45). Split time shows cumulative time at each checkpoint (split 1: 0:30, split 2: 1:15). This stopwatch tracks lap times, useful for interval training, experiment trials, or measuring repeated tasks.
Why do browser timers have accuracy limits?
Browser timers (setInterval, setTimeout) are not perfectly accurate due to: JavaScript being single-threaded (timers queue behind other code), browser throttling for battery saving (especially in background tabs), OS scheduling priorities, and the Spectre/Meltdown security patches that reduced timer resolution to mitigate side-channel attacks.
Can I use this stopwatch for professional timing?
For casual use (workouts, cooking, presentations) this stopwatch is sufficient. For professional timing (sports competitions, scientific experiments, legal depositions), use dedicated timing equipment with certified accuracy. Browser timers have ±10-50ms variance and may throttle in background tabs.