setHours()

The setHours() method is used to set the hour of the day of the Date object to the hour (from 0 to 23, 24 hour time) specified within brackets, which may be referred to as the condition or argument of the method. The date object will then use this value for its operations. The date and time of your system clock is not consulted with this method.

syntax:

dateObjectName.setHours(hour)

EXAMPLE

dateObject = new Date();

dateObject.setHours(11);

document.write("The date is: " + dateObject.getHours());

The example shows the creation of a new Date object, called dateObject. The setHours() method is then set to 11. Then a document.write statement is declared with the getHours() method to display the new value of the dateObject after the string of text..