Date.getTime() (Method)

Returns the time value of a date/time.

Availability:

ECMAScript edition - 2
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Netscape Enterprise Server - 2.0
Opera - 3.0
Property/method value type:Time value
JavaScript syntax:-myDate.getTime()

The time value of the receiving object. This will be an integer that represents the time in milliseconds since the time origin at midnight on January the first, 1970.

This method returns the time value of the receiving object.

Example code:

   <!-- Hand and eye coordination and reaction timer -->

   <HTML>

   <HEAD></HEAD>

   <BODY>

   <DIV ID="ONE" STYLE="background-color:YELLOW">

   Click button 1 then button two as quickly as you can

   </DIV>

   <FORM>

   <INPUT TYPE="button" VALUE="1" onClick="clickMe1()">

   <INPUT TYPE="button" VALUE="2" onClick="clickMe2()">

   </FORM>

   <SCRIPT>

   function clickMe1()

   {

   myDate1 = new Date();

   myTime1 = myDate1.getTime();

   }

   function clickMe2()

   {

   myDate2 = new Date();

   myTime2 = myDate2.getTime();

   document.all.ONE.innerText = (myTime2 - myTime1) + " Milliseconds";

   }

   </SCRIPT>

   </BODY>

   </HTML>

See also:Date.prototype, Date.setTime()

Cross-references:

ECMA 262 edition 2 - section - 15.9.5.4

ECMA 262 edition 3 - section - 15.9.5.9