Availability: |
| ||||||
Property/method value type: | Time value | ||||||
JavaScript syntax: | - | myDate.setUTCHours(anHoursValue) | |||||
- | myDate.setUTCHours(anHoursValue, aMinutesValue) | ||||||
- | myDate.setUTCHours(anHoursValue, aMinutesValue, aSecondsValue) | ||||||
- | myDate.setUTCHours(anHoursValue, aMinutesValue, aSecondsValue, aMillisecondsValue) | ||||||
Argument list: | aMillisecondsValue | An optional value between 0 and 999 milliseconds | |||||
aMinutesValue | An optional value between 0 and 59 minutes | ||||||
anHoursValue | A value between 0 and 23 hours | ||||||
aSecondsValue | An optional value between 0 and 59 seconds |
The value is computed according to UTC time coordinates.
ECMA mandates that the minutes, seconds and milliseconds should be optional arguments. If the milliseconds value is omitted, the current milliseconds value is used as if the value had been supplied with a getUTCMilliseconds() method. Likewise, the seconds value behaves as if it had been supplied by a getUTCSeconds() method, and the minutes value as if getUTCMinutes() was used, if they are missing.
The result of this method is the new time value of the containing object having been adjusted by the values passed in as arguments.
<HTML> <HEAD></HEAD> <BODY> <SCRIPT> myDate = new Date(); myDay1 = myDate.getDay(); for(myEnum=1; myEnum<24; myEnum++) { myDate.setUTCHours(myDate.getHours()+1); myDay2 = myDate.getDay(); if(myDay1 != myDay2) { document.write("In "+myEnum+" hours time it will be tomorrow.<BR>"); } else { document.write("In "+myEnum+" hours time it will still be today.<BR>"); } } </SCRIPT> </BODY> </HTML>
Prev | Home | Next |
Date.setUTCFullYear() | Up | Date.setUTCMilliseconds() |
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. |