Date.setTime() (Method)

Sets the time value of the time object.

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.setTime(aTimeValue)
Argument list:aTimeValueA value measured in milliseconds since midnight on any date.

The time value is extracted by clipping off any overflow past 24 hours. This is done with the internal TimeClip() method. The value of the receiving object is set to the resulting value. That same value is returned as the result of the method.

The result is a time clipped to modulo 24 hours.

Example code:

   <HTML>
   <HEAD></HEAD>
   <BODY onMouseMove="moved()">
   Move mouse horizontally to change day number
   <DIV ID="ONE" STYLE="background-color:YELLOW">?</DIV>
   <SCRIPT>
   myArray = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
   myDate = new Date();
   function moved(anEvent)
   {
   myDate.setTime(event.x * 1000000);
   document.all.ONE.innerText = myArray[myDate.getDay()];
   }
   </SCRIPT>
   </BODY>
   </HTML>

See also:Date.getTime(), Date.prototype, TimeClip()

Cross-references:

ECMA 262 edition 2 - section - 15.9.5.23

ECMA 262 edition 3 - section - 15.9.5.27