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.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
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()
Call
What it does
event.timeStamp
Learn jQuery event.timeStamp: milliseconds since Unix epoch when the browser created the event, official click-interval demo, vs Date.getTime(), profiling, double-click and throttle patterns, Firefox caveat, examples, and FAQs.
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Keep a last variable outside the handler.
Step 2
On each event, if last exists, compute diff = event.timeStamp - last.
Step 3
Use diff for intervals, double-click checks, or throttles.
Return Value
Return Value
Description
Value / undefined
Getters usually return a value from the first matched element, or undefined when nothing applies.
jQuery Examples
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.
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"
);
});
event.timeStamp: 1712345678901
Date.getTime(): 1712345678903
handler lag: 2 ms
How It Works
Stamp. Fixed at event creation.
Now.getTime() runs when the handler runs.
Lag. Small positive difference is normal.
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).