Description
The setHours() method sets the hour (from 0 to 23), according to local time.
This method has the form:
Date.setHours(hour,min,sec,millisec)
Parameter | Description |
---|---|
hour | (required) An integer between 0 and 23 representing the hour |
min | (optional) An integer between 0 and 59 representing the minutes |
sec | (optional) An integer between 0 and 59 representing the seconds |
millisec | (optional) An integer between 0 and 999 representing the milliseconds |
Examples
The following example shows the basic use of this method.
<script>
var d = new Date();
d.setHours(15);
document.write(d);
</script>
This produces the following result:
Browser Support
Firefox | IE | Chrome | Opera | Safari |
---|---|---|---|---|