jQuery event.timeStamp Property

Beginner
6 min read
Updated: Oct 2026
5 examples
Live preview

What Is event.timeStamp?

event.timeStamp is a Number: milliseconds between when the browser created the event and January 1, 1970 (Unix epoch). Since jQuery 1.2.6. Useful for measuring gaps between events. For the current wall-clock time inside a handler, use (new Date).getTime() instead.

Remember
event.timeStamp   // Number — event birth time (epoch ms)

// Interval between two events
diff = event.timeStamp - last;
last = event.timeStamp;

// Current time inside the handler (not event birth):
(new Date).getTime()   // or Date.now()
NeedUse
When was the event created?event.timeStamp
Gap between two eventsevent.timeStamp - last
Wall clock in the handlerDate.now() / (new Date).getTime()
Work duration inside one handlerperformance.now()
Bind click / key handlers.on()

How to Use event.timeStamp

Store one stamp, subtract on the next event.

  1. Keep a last variable outside the handler.
  2. On each event, if last exists, compute diff = event.timeStamp - last.
  3. Use diff for intervals, double-click checks, or throttles.
  4. Always update last = event.timeStamp.
  5. Do not treat timeStamp as “now” — that is Date.now().
PieceRequired?Role
event argumentYesjQuery event object
event.timeStampYesEvent creation time (epoch ms)
last variableFor intervalsPrevious stamp to subtract from
Date.now()OptionalCurrent time when handler runs

Pseudocode

Pseudocode
last = undefined

on each event:
    if last exists:
        diff = event.timeStamp - last
        // use diff (interval, throttle, double-click…)
    else:
        // first event — no interval yet
    last = event.timeStamp

Cheat Sheet

Keep these facts handy while timing events.

TopicDetail
TypeProperty → Number
SincejQuery 1.2.6
UnitMilliseconds since Unix epoch
MeaningWhen the browser created the event
Not for“Current time” inside the handler
FirefoxUnreliable — use other clocks if needed

Live Preview

Click repeatedly — the log shows the gap since the last click, like the official demo.

Interval

First click arms the timer; later clicks print the delta in ms.

Log
Click to start.

jQuery Examples

Short labs — each has View Output, Try It Yourself, and How It Works.

Example 1 — Official Click Interval

Measure milliseconds between consecutive clicks.

jQuery
var last, diff;
$("#box").on("click", function (event) {
  if (last) {
    diff = event.timeStamp - last;
    $("#out").append("time since last event: " + diff + "\n");
  } else {
    $("#out").append("Click again.\n");
  }
  last = event.timeStamp;
});
Try It Yourself

How It Works

  1. First click. No last yet — prompt again.
  2. Later clicks. Subtract stamps for the gap.
  3. Append. Show the delta in ms.
  4. Update. Save this stamp for the next click.

Example 2 — Handler Profiling

Show event birth time and work duration with performance.now().

jQuery
$("#run").on("click", function (event) {
  var t0 = performance.now();
  var birth = event.timeStamp;
  for (var i = 0; i < 1e6; i++) {}
  var t1 = performance.now();
  $("#out").text(
    "event.timeStamp: " + birth + "\n" +
    "handler work: " + (t1 - t0).toFixed(2) + " ms"
  );
});
Try It Yourself

How It Works

  1. Birth. timeStamp is when the event was created.
  2. Work clock. performance.now() measures loop time.
  3. Separate roles. Stamp ≠ work duration.
  4. API tip. Official docs suggest stamps for profiling gaps.

Example 3 — vs Date.getTime()

Event creation time vs wall clock when the handler runs.

jQuery
$("#btn").on("click", function (event) {
  var now = (new Date()).getTime();
  var lag = now - event.timeStamp;
  $("#out").text(
    "event.timeStamp: " + event.timeStamp + "\n" +
    "Date.getTime(): " + now + "\n" +
    "handler lag: " + lag + " ms"
  );
});
Try It Yourself

How It Works

  1. Stamp. Fixed at event creation.
  2. Now. getTime() runs when the handler runs.
  3. Lag. Small positive difference is normal.
  4. Rule. Need “now”? Use Date — not timeStamp.

Example 4 — Double-Click Interval

Treat a second click within 300 ms as a double-click.

jQuery
var lastClick = 0;
$("#item").on("click", function (event) {
  var delta = event.timeStamp - lastClick;
  if (lastClick && delta < 300) {
    $("#out").text("Double-click (" + Math.round(delta) + " ms)");
    lastClick = 0;
  } else {
    $("#out").text("Single click — click again quickly");
    lastClick = event.timeStamp;
  }
});
Try It Yourself

How It Works

  1. First click. Save the stamp.
  2. Second click. Compute delta.
  3. Threshold. Under 300 ms → double-click.
  4. Reset. Clear lastClick after a pair.

Example 5 — Keydown Throttle

Ignore key events closer than 200 ms.

jQuery
var lastKey = 0;
$("#search").on("keydown", function (event) {
  if (event.timeStamp - lastKey < 200) {
    return;
  }
  lastKey = event.timeStamp;
  $("#out").text("Handled key at " + Math.round(lastKey));
});
Try It Yourself

How It Works

  1. Gate. Skip if delta < 200 ms.
  2. Accept. Update lastKey and handle.
  3. Use case. Limit work on held keys or fast typing.
  4. Firefox. Prefer Date.now() if stamps misbehave.

Edge Cases & Pitfalls

Watch for these when reading event times.

now

Not the current time

Inside a handler, “now” is Date.now() — timeStamp is event birth time.

ff

Firefox values

Stamps may be wrong in Firefox. Fall back to Date.now() when precision matters.

first

First event has no delta

Guard with if (last) before subtracting — otherwise you invent a huge interval.

clock

Wrong tool for work timing

Measure code inside one handler with performance.now(), not two different clocks mixed carelessly.

Browser Support

event.timeStamp is a standard DOM Event property. jQuery exposes it on the normalized event object since 1.2.6. Works in Chromium and Safari; Firefox values are unreliable due to a long-standing bug.

✓ Stable · Caution in Firefox

event.timeStamp

Supported via the DOM Event API. Prefer jQuery 3.x. For cross-browser timing that must work in Firefox, use Date.now() or performance.now() as a fallback.

High* Property support
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
timeStamp High*

Bottom line: Safe for demos and most Chromium/Safari apps. Treat Firefox as a known caveat; fall back when exact creation time matters.

Performance Notes

ApproachCostBest for
Read event.timeStampFreeIntervals between events
Subtract two stampsFreeClick gaps, throttles
Date.now() fallbackTinyFirefox-safe wall clock
performance.now()TinyWork duration inside one handler

Reading and subtracting stamps is effectively free. The value is skipping expensive work via throttles — not the clock call itself.

Key Takeaways

  • Role: epoch ms when the browser created the event.
  • Intervals: subtract consecutive stamps.
  • Not now: use Date.now() for wall-clock time in the handler.
  • Firefox: stamps may be wrong — plan a fallback.

One line: event.timeStamp answers “when was this event created?” — subtract two to get the gap.

Frequently Asked Questions

event.timeStamp is a Number: milliseconds between when the browser created the event and January 1, 1970 (Unix epoch). Available since jQuery 1.2.6. It is the event creation time — not the current wall-clock time when your handler runs.
Store the previous event.timeStamp. On the next event: diff = event.timeStamp - last. The official demo appends that delta in milliseconds, then updates last = event.timeStamp.
No. event.timeStamp is fixed when the browser created the event. For current wall-clock time when your handler executes, use (new Date).getTime() or Date.now() instead.
Firefox has a long-standing bug where event.timeStamp is not populated correctly. Do not rely on it for exact event creation time in Firefox. Prefer Date.now() or performance.now() when cross-browser precision matters.
event.timeStamp is epoch milliseconds at event creation — subtract two values to get an interval. performance.now() is a high-resolution monotonic clock from navigation start, ideal for measuring work inside one handler.
Yes. Store the last handled timeStamp and ignore later events until the delta exceeds your threshold (for example 200 ms on keydown).

Next: click event

Practice click handlers — the usual place to read timeStamp.

click tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful