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.
<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() |
Prev | Home | Next |
Date.getUTCFullYear() | Up | Date.getUTCMilliseconds() |
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. |