Date.getUTCHours() (Method)

Returns the UTC hours value for a date/time.

Availability:

ECMAScript edition - 2
JavaScript - 1.2
JScript - 3.0
Internet Explorer - 4.0
Netscape - 4.0
Property/method value type:Number primitive
JavaScript syntax:-myDate.getUTCHours()

The result of this method is the hours component of the time value contained in the receiving object. The value will be in the range 0 to 23 inclusive.

The value is computed according to UTC time coordinates.

Example code:

   <HTML>

   <HEAD></HEAD>

   <BODY>

   <SCRIPT>

   // Generate a flag based on work or play time

   myDate = new Date();

   myHours = myDate.getUTCHours();

   if((myHours > 8) && (myHours < 17))

   {

   document.write("At work");

   }

   else

   {

   document.write("At play");

   }

   </SCRIPT>

   </BODY>

   </HTML>

See also:Date.prototype, Date.setUTCHours()

Cross-references:

ECMA 262 edition 2 - section - 15.9.5.15

ECMA 262 edition 3 - section - 15.9.5.19