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()
On each event, if last exists, compute diff = event.timeStamp - last.
Use diff for intervals, double-click checks, or throttles.
Always update last = event.timeStamp.
Do not treat timeStamp as “now” — that is Date.now().
Piece
Required?
Role
event argument
Yes
jQuery event object
event.timeStamp
Yes
Event creation time (epoch ms)
last variable
For intervals
Previous stamp to subtract from
Date.now()
Optional
Current 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
Reference
Cheat Sheet
Keep these facts handy while timing events.
Topic
Detail
Type
Property → Number
Since
jQuery 1.2.6
Unit
Milliseconds since Unix epoch
Meaning
When the browser created the event
Not for
“Current time” inside the handler
Firefox
Unreliable — use other clocks if needed
Try it
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.
Practice
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;
});
event.timeStamp: 1712345678901
handler work: 3.42 ms
How It Works
Birth.timeStamp is when the event was created.
Work clock.performance.now() measures loop time.
Separate roles. Stamp ≠ work duration.
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"
);
});
Handled key at 1712345679100
(rapid repeats within 200 ms are ignored)
How It Works
Gate. Skip if delta < 200 ms.
Accept. Update lastKey and handle.
Use case. Limit work on held keys or fast typing.
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.
Compatibility
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 ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
timeStampHigh*
Bottom line: Safe for demos and most Chromium/Safari apps. Treat Firefox as a known caveat; fall back when exact creation time matters.
Analysis
Performance Notes
Approach
Cost
Best for
Read event.timeStamp
Free
Intervals between events
Subtract two stamps
Free
Click gaps, throttles
Date.now() fallback
Tiny
Firefox-safe wall clock
performance.now()
Tiny
Work duration inside one handler
Reading and subtracting stamps is effectively free. The value is skipping expensive work via throttles — not the clock call itself.
Remember
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).