August 1999
Intermediate to advanced
1488 pages
72h 53m
English
date.getHours()
The getHours() method returns the hour portion of the date expressed as an integer from 0 (12:00 a.m. midnight) to 23 (11:00 p.m.).
The code in Listing 6.74 displays the current hour as an integer from 0 to 23 using the getHours() method.
<html>
<script language="JavaScript">
<!-- Hide
//Create a Date object that contains the current date and time.
theDate = new Date();
//Display the hour
document.write("The hour is ",theDate.getHours());
//Hide End -->
</script>
</html>
|
Read now
Unlock full access