jQuery event.timeStamp

Beginner
⏱️ 8 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Event object · jQuery 1.2.6+

What You’ll Learn

event.timeStamp records when the browser created the event — epoch milliseconds you can subtract to measure gaps between clicks or key presses. This tutorial covers the official consecutive-click demo, handler profiling, comparing with Date.getTime() and performance.now(), double-click detection, input throttling, and the Firefox caveat.

01

Property

event.timeStamp

02

Returns

Number (ms)

03

Official

Click delta

04

Profile

Handler timing

05

Not now

Event birth time

06

Since 1.2.6

All events

Introduction

Every jQuery handler receives an event object. Among its properties, event.timeStamp answers: when did the browser create this event? The value is a number — milliseconds between that moment and January 1, 1970 (the Unix epoch). It is not updated while your handler runs; reading it twice inside the same callback returns the same number.

jQuery has exposed event.timeStamp since version 1.2.6. The official docs highlight profiling: store event.timeStamp at one point, read it again on a later event, and note the difference. The canonical demo compares consecutive clicks with diff = event.timeStamp - last. For current wall-clock time inside a handler, use (new Date).getTime() instead — not timeStamp.

Understanding event.timeStamp

event.timeStamp is the browser’s record of event creation time in epoch milliseconds:

  • Fixed per event — set when the browser dispatches the event; unchanged for the lifetime of that event object.
  • Comparable across events — subtract two timestamps to get milliseconds between user actions (clicks, keydowns).
  • Not handler “now” — if work delays your callback, timeStamp still reflects creation time, not when your code runs.
  • Profiling aid — official pattern: read at start and end of handler work, or compare consecutive events via a stored last variable.
💡
Beginner Tip

Need “right now” inside the handler? Call (new Date).getTime() or Date.now(). Need “when did this click happen?” or “ms since last click?” — use event.timeStamp and subtraction.

📝 Syntax

Official jQuery API form (since 1.2.6):

jQuery
event.timeStamp

// read inside any .on() handler:
function handler( event ) {
  var created = event.timeStamp;
  console.log( "Event created at epoch ms:", created );
}

// consecutive events — official delta pattern:
var last;
$( "div" ).on( "click", function ( event ) {
  if ( last ) {
    var diff = event.timeStamp - last;
    console.log( "ms since last:", diff );
  }
  last = event.timeStamp;
});

Type

  • Number — milliseconds since January 1, 1970 UTC at event creation.

Return value

  • Not a method — a read-only property on the event object passed to your handler.
  • Same value for the entire dispatch of that event — subtract across events, not across lines in one handler expecting “now”.

Official jQuery API example

jQuery
var last, diff;
$( "div" ).on( "click", function ( event ) {
  if ( last ) {
    diff = event.timeStamp - last;
    $( "div" ).append( "time since last event: " + diff + " " );
  } else {
    $( "div" ).append( "Click again. " );
  }
  last = event.timeStamp;
});

⚡ Quick Reference

APIMeasuresBest for
event.timeStampEpoch ms at event creationGap between two user events
Date.getTime() / Date.now()Epoch ms when you call itWall clock “now” in handler
performance.now()Ms since navigation startHigh-res work inside one handler
event.timeStamp - lastMs between consecutive eventsThrottle, double-click, click spacing
last = event.timeStampStore for next comparisonOfficial consecutive-click demo

📋 timeStamp vs Date.getTime() vs performance.now() vs Date.now()

Four timing APIs beginners mix up — each answers a different question.

timeStamp
event.timeStamp

When browser created this event (epoch ms)

Date.getTime()
(new Date).getTime()

Wall clock now when handler runs

Date.now()
Date.now()

Same epoch ms as getTime() — shorthand

performance.now()
performance.now()

Monotonic high-res timer for in-handler work

Examples Gallery

Example 1 follows the official consecutive-click demo. Examples 2–5 cover handler profiling, timeStamp vs wall clock, double-click interval detection, and keydown throttling.

📚 Official jQuery Demo

Measure milliseconds between consecutive clicks on a div.

Example 1 — Official Demo: time since last click on div

Official jQuery pattern — first click prompts “Click again.” Later clicks append time since last event: {diff} using event.timeStamp - last.

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

How It Works

event.timeStamp is fixed when the browser creates each click event. Subtracting the previous stored value yields the gap between user actions — the official profiling pattern from the jQuery API docs.

Example 2 — Handler profiling: measure work at start vs end

Capture performance.now() at handler entry and exit for in-handler duration; log event.timeStamp once to show event birth time stays constant.

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

How It Works

The official docs suggest reading timeStamp at two points to note differences — across events that means subtracting stored values. Inside one handler, performance.now() measures elapsed work; event.timeStamp only records when the event was born.

📈 Practical Patterns

Wall clock comparison, double-click detection, and keyboard throttling.

Example 3 — timeStamp vs Date.getTime(): creation vs now

Log both values in the same handler — event.timeStamp is event birth time; (new Date).getTime() is wall clock when your code runs.

jQuery
$( "button" ).on( "click", function ( event ) {
  var now = ( new Date ).getTime();
  var lag = now - event.timeStamp;
  $( "#log" ).html(
    "event.timeStamp: " + event.timeStamp + "
" + "Date.getTime(): " + now + "
" + "handler lag: " + lag + " ms" ); });
Try It Yourself

How It Works

jQuery docs explicitly say: for current time inside a handler, use (new Date).getTime(). The gap now - event.timeStamp shows how long after event creation your handler actually ran — useful when debugging slow main-thread queues.

Example 4 — Double-click interval: rapid second click within ~300 ms

Track last click timestamp; when event.timeStamp - last < 300, treat as double-click.

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

How It Works

Subtracting consecutive event.timeStamp values measures inter-click spacing without polling a clock. Reset lastClick after a double-click so a third click starts a fresh sequence.

Example 5 — Input throttle: ignore keydown if delta < 200 ms

Store last keydown event.timeStamp; skip handler body when events arrive faster than 200 ms apart.

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

How It Works

Early return when event.timeStamp - lastKey < 200 throttles expensive autocomplete or search logic. Update lastKey only when you actually handle the event — mirrors the official consecutive-event subtraction pattern.

🚀 Common Use Cases

  • Click spacing — official demo: diff = event.timeStamp - last between consecutive clicks.
  • Handler profiling — compare timestamps at two code points or use performance.now() inside one handler.
  • Double-click detection — threshold on event.timeStamp - lastClick (~300 ms).
  • Input throttling — ignore keydown/keyup when delta from last handled event is below 200 ms.
  • Event ordering — compare creation times when debugging race conditions between rapid events.
  • Debug lagDate.now() - event.timeStamp shows queue delay before your handler ran.

🧠 How event.timeStamp Is Set

1

User action

Browser creates a native event (click, keydown, etc.) and stamps it with creation time in epoch milliseconds.

Trigger
2

jQuery normalizes

Your handler receives jQuery’s event object with event.timeStamp copied from the native event — a Number since 1.2.6.

Handler
3

Value stays fixed

Reading event.timeStamp again in the same handler returns the same number — it is not updated to “now”.

Immutable
4

Subtract across events

Store last = event.timeStamp and compute deltas on the next event — the official profiling pattern.

📝 Notes

  • Available since jQuery 1.2.6 — returns a Number (epoch milliseconds at event creation).
  • Measures time between event creation and January 1, 1970 — not current time inside the handler.
  • For wall clock now, use (new Date).getTime() or Date.now() — as stated in the official jQuery docs.
  • Official profiling pattern: read at two points and note the difference; consecutive clicks use event.timeStamp - last.
  • Firefox caveat — long-standing bug: timeStamp not populated correctly; exact event creation time unavailable there.
  • For in-handler duration, prefer performance.now() over re-reading event.timeStamp.
  • Read-only — store in a variable if you need the value after async work in the same dispatch.

Browser Support

event.timeStamp is a standard DOM Event property exposed on jQuery’s normalized event object since jQuery 1.2.6+. Chromium, Safari, and Edge populate it reliably for inter-event deltas. Firefox has a documented long-standing bug where the value is not set correctly — test timing logic accordingly.

jQuery 1.2.6+ · DOM standard

jQuery event.timeStamp

Event creation epoch ms — subtract across events.

95% Wide 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 Number (ms)

Bottom line: Reliable in Chrome/Safari/Edge; verify Firefox separately.

Conclusion

event.timeStamp tells you when the browser created the event — epoch milliseconds fixed for that dispatch. The official demo subtracts consecutive values to show time between clicks, and the same pattern powers throttling and double-click detection.

Reach for Date.getTime() or Date.now() when you need current wall clock time, and performance.now() for high-resolution work inside a handler. Remember the Firefox caveat before relying on precise creation times everywhere.

💡 Best Practices

✅ Do

  • Subtract event.timeStamp - last for gaps between consecutive user events
  • Store last = event.timeStamp after each handled event in throttle/delta patterns
  • Use (new Date).getTime() when you need current wall-clock time in the handler
  • Use performance.now() to measure work duration inside one handler
  • Test timing features in Chrome, Safari, and Edge; plan Firefox fallbacks

❌ Don’t

  • Treat event.timeStamp as “now” — it is event birth time only
  • Re-read event.timeStamp expecting it to advance during long synchronous work
  • Assume Firefox provides accurate timeStamp values without verification
  • Confuse epoch timeStamp with monotonic performance.now() origins
  • Forget to reset stored last after double-click or throttle sequences end

Key Takeaways

Knowledge Unlocked

Five things to remember about event.timeStamp

Event birth time — subtract across events.

5
Core concepts
# 02

Number

Epoch ms

Type
03

Delta

last diff

Demo
now 04

Date

Wall clock

Compare
FF 05

Firefox

Bug caveat

Note

❓ Frequently Asked Questions

event.timeStamp is a Number on the jQuery event object. It returns the number of 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 in a variable. On the next event, subtract: diff = event.timeStamp - last. The official jQuery demo appends the diff in milliseconds. Then update last = event.timeStamp for the next comparison.
No. event.timeStamp is fixed when the browser created the event. For current wall-clock time when your handler executes, use (new Date).getTime(), Date.now(), or performance.now() instead.
Bind click on a div. On first click append "Click again." On later clicks compute diff = event.timeStamp - last and append "time since last event: " + diff. Set last = event.timeStamp each time.
Firefox has a long-standing bug where event.timeStamp is not populated correctly. You cannot rely on it for exact event creation time in Firefox. Test profiling and throttle logic in Chrome, Safari, and Edge; add fallbacks or skip Firefox-specific timing if precision matters.
event.timeStamp is epoch milliseconds at event creation — comparable across two events via subtraction. performance.now() is a high-resolution monotonic clock from navigation start, ideal for measuring work inside one handler. Date.getTime() and Date.now() return current wall-clock epoch ms when you call them — not the event birth time.
Did you know?

The jQuery API has documented a Firefox bug with event.timeStamp for years — the property exists on the event object but is not populated correctly, so you cannot know the exact event creation time in Firefox. The official docs recommend (new Date).getTime() when you need current time inside a handler, which sidesteps confusion between event birth time and handler execution time.

Next: Click Event

Learn how to bind click handlers, prevent defaults, and stop propagation.

Click Event 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.

6 people found this page helpful