Displaying Dates by Time Zone

By default, the dates and times that are displayed are those on the user’s machine (assuming that they are set correctly). If you want to display a date somewhere else, you need to calculate it based on UTC, Coordinated Universal Time. UTC is essentially a different name for Greenwich Mean Time (GMT); UTC also goes under the names “universal time” (UT) and “world time.” Script 12.4 shows the HTML for the page; Script 12.5, with the JavaScript, shows you how to calculate dates in other time zones.

To display dates by time zone:

1.
var allTags = document.getElementsByTagName("*");
Inside the initDate() function, create the allTags variable. The command document.getElementsByTagName("*") is a handy trick—that asterisk ...

Get JavaScript and Ajax for the Web: Visual QuickStart Guide, Seventh 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.