You are here: Reference > JavaScript > client-side > event handling > properties > timeStamp (event)

timeStamp property (event)

Browser support:
Returns the time in milliseconds when the current event occurred.
In Firefox, the returned time is relative to the time when the client's computer started up. In Opera, the value of the timeStamp property is always 0. In Google Chrome, Safari and Internet Explorer, the returned time is relative to midnight 01 January, 1970 UTC.
The timeStamp property is supported in Internet Explorer from version 9. For a cross-browser solution, use the Date object instead.


You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

Integer that represents the number of milliseconds.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the timeStamp property:
    <script type="text/javascript">
        var lastClick = -1;
        var fastest = -1;
        function GetElapsedTime (event) {
            if ('timeStamp' in event) {
                var timeStamp = event.timeStamp;
            else {
                var date = new Date ();
                var timeStamp = date.getTime ();
            if (lastClick < 0) {
                lastClick = timeStamp;

            var elapsed = timeStamp - lastClick;
            if (fastest < 0 || elapsed < fastest) {
                fastest = elapsed;
                var fastestSpan = document.getElementById ("fastest");
                fastestSpan.innerHTML = elapsed;
            lastClick = timeStamp;

            var timeInfo = document.getElementById ("timeInfo");
            timeInfo.innerHTML = elapsed;
    Click several times on this button:
    <button id="myButton" onmouseup="GetElapsedTime (event);">Elapsed time test!</button>
    <br /><br  />
    Elapsed time: <span id="timeInfo"></span> ms
    <br />
    Fastest: <span id="fastest" style="color:red"></span> ms
Did you find this example helpful? yes no

Supported by objects:

External links:

User Contributed Comments

Post Content

Post Content