Availability: |
| ||||||||
Property/method value type: | Time value | ||||||||
JavaScript syntax: | - | myDate.setTime(aTimeValue) | |||||||
Argument list: | aTimeValue | A 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.
<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() |
Prev | Home | Next |
Date.setSeconds() | Up | Date.setUTCDate() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |