The computations are done based on extracting a local time value and changing the millisecond count for that, before storing it back again as a local time value.
The result of this method is the new time value having had the milliseconds component set according to the passed-in argument.
<HTML>
<HEAD></HEAD>
<BODY>
<SCRIPT>
myDate = new Date();
myDate.setMilliseconds(0);
myTime = myDate.getTime();
document.write("The time rounded down to the nearest second is " + myTime + " Milliseconds");
</SCRIPT>
</BODY>
</HTML>| Prev | Home | Next |
| Date.setHours() | Up | Date.setMinutes() |
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. | ||