HTML and CSS Reference
In-Depth Information
Figure 11-26 highlights the changes to the code.
Figure 11-26
Minutes and seconds variables added to the nYclock() function
rounds the minutes value
down to the n e arest integer
calculates the
minutes left in the
current hour
calculates the
seconds left in the
current minute
rounds the seconds value down to the neare st integer
6. Save your changes to the file.
7. Reopen or refresh clock.htm in your Web browser. The Web form displays the
time left in integer values of days, hours, minutes, and seconds. See Figure 11-27.
Figure 11-27
displaying the integer numbers of minutes and seconds
integer number
of minutes left
in the h o ur
integer number
of seconds left
in the minute
In some cases, the countdown value may show an extra (or missing) hour, minute, or
second. Why is that? Several factors are involved. One is the presence of daylight sav-
ing time, which moves the clock forward (or backward) one hour. If your time interval
crosses this event, the hours left value will appear off as an hour is added to or sub-
tracted from the time interval. Another factor is that the day is not evenly divided into
seconds (that's one reason that JavaScript measures time in milliseconds). A fraction of a
Search WWH ::

Custom Search