Assignment

Write a clock that tells the time in San Francisco, New York, London, and Tokyo. The clock should have a text field for the time, a button to update the clock, and four radio buttons, each for a different time zone. When you click one of the radio buttons, the correct time should appear in the text field. When you click the update button, the clock should update with the time from the zone you've selected with the radio buttons. Figure 7-29 shows an example.

Updating the time for different cities

Figure 7-29. Updating the time for different cities

First you'll need some information about looking up time. Remember from Chapter 2 how to get the current hour:

var now = new Date(); ...

Get The Book of JavaScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.