Date.setUTCHours() (Method)

Sets the UTC hours of the time object.

Availability:

ECMAScript edition - 2
JavaScript - 1.3
JScript - 3.0
Internet Explorer - 4.0
Netscape - 4.0
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:aMillisecondsValueAn optional value between 0 and 999 milliseconds
aMinutesValueAn optional value between 0 and 59 minutes
anHoursValueA value between 0 and 23 hours
aSecondsValueAn 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.

Example code:

   <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>

See also:Date.getHours(), Date.getUTCHours(), Date.prototype, Date.setHours()

Cross-references:

ECMA 262 edition 2 - section - 15.9.5.31

ECMA 262 edition 3 - section - 15.9.5.35