The above solution is very simple. The code to look up the time and describe how to display it is actually longer than the code to keep time. However, this solution does not measure up in a real-world web application. There are two particular problems that this does not address.
Another solution that I tried was to have the system check the system clock each time the tick function executes and adjust the amount of time until the next tick accordingly. This was a bit more complicated, and ultimately didn't work much better than the above solution in my tests.
Do bear in mind, though, that in this more advanced solution, the tick function is not being used to keep track of the actual time. Instead, the tick function is used only to update the display time, which is accomplished by taking the current time on the client's clock and adding back the offset that we computed at the beginning.
There is one definite pitfall with this solution, however. Although we don't count on the client clock to have the correct time when the code starts, we do count on the client clock accurately tracking how many milliseconds have elapsed. In other words, the user can still make this program behave erratically by changing the client clock as the program runs.