Mozilla.com

Summary

Sets the hours for a specified date according to local time.

Method of Date
Implemented in: JavaScript 1.0, NES 2.0

JavaScript 1.3: Added minutesValue, secondsValue, and msValue parameters.

ECMA Version: ECMA-262

Syntax

setHours(hoursValue[, minutesValue[, secondsValue[, msValue]]])

Versions prior to JavaScript 1.3

setHours(hoursValue)

Parameters

hoursValue 
An integer between 0 and 23, representing the hour.
minutesValue 
An integer between 0 and 59, representing the minutes.
secondsValue 
An integer between 0 and 59, representing the seconds. If you specify the secondsValue parameter, you must also specify the minutesValue.
msValue 
A number between 0 and 999, representing the milliseconds. If you specify the msValue parameter, you must also specify the minutesValue and secondsValue.

Description

If you do not specify the minutesValue, secondsValue, and msValue parameters, the values returned from the getUTCMinutes, getUTCSeconds, and getMilliseconds methods are used.

If a parameter you specify is outside of the expected range, setHours attempts to update the date information in the Date object accordingly. For example, if you use 100 for secondsValue, the minutes will be incremented by 1 (min + 1), and 40 will be used for seconds.

Examples

Example: Using setHours

theBigDay.setHours(7)

See Also

getHours, setUTCHours

Languages

Page last modified 20:19, 11 Apr 2006 by Ptak82

Tags:

Files (0)