event.timeStamp

  • Revision slug: DOM/event.timeStamp
  • Revision title: event.timeStamp
  • Revision id: 333209
  • Created:
  • Creator: ethertank
  • Is current revision? No
  • Comment id ...etc.

Revision Content

{{DomRef}}

Summary

Returns the time (in milliseconds since the epoch) at which the event was created.

Syntax

event.timeStamp

Examples

var number = event.timeStamp;

The following is a more complete example:

<html>
<head>

<title>timeStamp example</title>

<script type="text/javascript">
function getTime(event) {
  document.getElementById("time").firstChild.nodeValue = event.timeStamp;
}
</script>
</head>

<body onkeypress="getTime(event)">

<p>Press any key to get the current timestamp
for the onkeypress event.</p>
<p>timeStamp: <span id="time">-</span></p>

</body>
</html>

Notes

This property only works if the event system supports it for the particular event.

Specification

Revision Source

<div>{{DomRef}}</div>
<h2 id="Summary" name="Summary">Summary</h2>
<p>Returns the time (in milliseconds since the epoch) at which the event was created.</p>

<h3 id="Syntax" name="Syntax">Syntax</h3>
<pre class="syntaxbox">
event.timeStamp
</pre>

<h2 id="Examples" name="Examples">Examples</h2>
<pre>
<em>var number</em> = event.timeStamp;
</pre>

<p>The following is a more complete example:</p>

<pre class="brush: html">
&lt;html&gt;
&lt;head&gt;

&lt;title&gt;timeStamp example&lt;/title&gt;

&lt;script type="text/javascript"&gt;
function getTime(event) {
  document.getElementById("time").firstChild.nodeValue = event.timeStamp;
}
&lt;/script&gt;
&lt;/head&gt;

&lt;body onkeypress="getTime(event)"&gt;

&lt;p&gt;Press any key to get the current timestamp
for the onkeypress event.&lt;/p&gt;
&lt;p&gt;timeStamp: &lt;span id="time"&gt;-&lt;/span&gt;&lt;/p&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>

<h2 id="Notes" name="Notes">Notes</h2>
<p>This property only works if the event system supports it for the particular event.</p>

<h2 id="Specification" name="Specification">Specification</h2>
<ul>
<li><a class="external" href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-Event-timeStamp">timestamp </a></li>
</ul>
Revert to this revision