JavaScript Event timeStamp Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

Event.timeStamp is a read-only number: milliseconds from the page’s (or worker’s) time origin until the event was created. It is a DOMHighResTimeStamp. (MDN: Baseline Widely available since July 2015; also in Web Workers.)

Read the notes below before you rely on this property. Prefer feature detection when support is limited.

Syntax

Use event.timeStamp. Start with this line.

JavaScript
event.timeStamp
CallWhat it does
event.timeStampPrimary signature.

Built into the browser. Read event.timeStamp on an Event instance — no import required.

Library declarations
JavaScript
event.timeStamp

Parameters

ParameterDescription
Previous stampOptional. Needed only for deltas

Return Value

Return ValueDescription
*The current value of event.timeStamp.

JavaScript Examples

Example 1 — Read timeStamp on Click

Log the milliseconds since the time origin when the button is clicked.

JavaScript
button.addEventListener("click", (event) => {
  console.log(event.timeStamp);
});
Try It Yourself

How It Works

  1. Listen for click. The handler receives a real Event.
  2. Read the stamp. event.timeStamp is ms since the time origin.
  3. Number type. It is a high-resolution timestamp (may look fractional).
  4. Varies per load. A later page load starts a new time origin.

Example 2 — Keypress Demo (MDN Pattern)

Press a key and show event.timeStamp in the page.

JavaScript
function getTime(event) {
  document.getElementById("time").textContent = event.timeStamp;
}

document.body.addEventListener("keypress", getTime);
Try It Yourself

How It Works

  1. Listen on body. Keypress events bubble to it when focus is in the document.
  2. Press a key. The handler runs with the key event.
  3. Write the stamp. Update a text node / element with event.timeStamp.
  4. Same idea as MDN. Useful for seeing live values while typing.

Example 3 — Milliseconds Between Clicks

Subtract the previous stamp from the current one to get a delta.

JavaScript
let last = null;

button.addEventListener("click", (event) => {
  if (last !== null) {
    console.log(event.timeStamp - last); // ms since last click
  }
  last = event.timeStamp;
});
Try It Yourself

How It Works

  1. Keep last. Store the previous event’s stamp (or null at first).
  2. First click. No delta yet — only save the stamp.
  3. Later clicks. current - last is the gap in milliseconds.
  4. Same origin. Both values share the page time origin, so subtraction is meaningful.

Browser Support

Event.timeStamp is marked Baseline Widely available on MDN (since July 2015). It is also available in Web Workers. Precision may be reduced for privacy.

✓ Baseline · Widely available

Event.timeStamp

Read-only DOMHighResTimeStamp: milliseconds from the time origin until the event was created.

Universal Widely available
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
Event.timeStamp Excellent

Bottom line: Safe to use for relative event timing. Expect rounded values; prefer deltas over absolute stamps for UX logic.

Frequently Asked Questions

It is a read-only number on an Event: the time in milliseconds when the event was created, measured from the relevant global object’s time origin (a DOMHighResTimeStamp).
No. MDN marks Event.timeStamp as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard. It is also available in Web Workers.
In a window, it is typically when navigation to the document started. In a worker, it is when the worker was created. event.timeStamp counts milliseconds from that origin.
Browsers often reduce precision to help prevent fingerprinting and timing attacks. Fractional milliseconds do not always mean full precision. Values are still useful for relative deltas.
Store the first event.timeStamp, then subtract it from a later event.timeStamp. The delta is in milliseconds (subject to reduced precision).
No. Date.now() is wall-clock time since the Unix epoch. event.timeStamp is relative to the document/worker time origin—better for comparing event timing within a page.

Next: type

Read the event name string — "click", "keydown", and more.

type 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.

8 people found this page helpful