The computations are done based on extracting a UTC time value and changing the millisecond count for that before storing it back, again as a UTC 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.setUTCMilliseconds(0); myTime = myDate.getTime(); document.write("The time rounded down to the nearest second is " + myTime + " Milliseconds"); </SCRIPT> </BODY> </HTML>
Prev | Home | Next |
Date.setUTCHours() | Up | Date.setUTCMinutes() |
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. |