jQuery event.timeStamp Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Events

Definition

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()
CallWhat it does
event.timeStampLearn 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

ParameterDescription
Step 1Keep a last variable outside the handler.
Step 2On each event, if last exists, compute diff = event.timeStamp - last.
Step 3Use diff for intervals, double-click checks, or throttles.

Return Value

Return ValueDescription
Value / undefinedGetters 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;
});
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.

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.

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.

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: Event Handler Methods

Practice click handlers — the usual place to read timeStamp.

Event Handler Methods tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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