Got the Time?

Reader Tim FitzPatrick sends in a great scripting tip for managing time across time zones.

By Don Jones

11/01/2006

Although time is a constant, it can also seem quite variable. Earlier this
year I provided some suggestions for inventorying and changing time zones on
Windows computers in the May 2006 Mr. Roboto, "Does
Anybody Really Know What Time It Is?"

Shortly after that column ran, I received a fascinating e-mail from Tim FitzPatrick. He has been doing some work for the Royal New Zealand Navy. Mr. Roboto was pleased to hear the Navy was reading up on Windows automation, but somewhat alarmed at the thought of VBScript being used on a guided missile cruiser.

Fear not, Tim isn't writing scripts to execute launch codes or run guidance systems. His biggest issue is with all the time zones the fleet passes through. The servers on board every ship are always set to Zulu time, in military parlance. That's what civilians call Greenwich Mean Time (GMT). That is the one global time zone with a zero offset, the time zone from which all others are calculated. All other time zones are offset from GMT by a number of hours or minutes. My own U.S. Pacific Time Zone, for example, is currently GMT -8:00.

So the onboard servers keep their time constant, which helps ships cruising in different time zones stay synchronized with one another and
probably saves the shipboard administrators a lot of hassle. However, the swabbies working on the ships will want to know the local time. GMT, or Zulu time, doesn't cut it when it's time to ring the dinner bell somewhere in the South Pacific.

The goal is to keep the workstations' clocks localized by changing their time zones. That way, they could sync time with a domain controller, and that time sync is always done in Zulu time. Then they could adjust accordingly to the local time, based on the time zone in which they're currently sailing.

Rather than sending newly enlisted seamen around to fix all the shipboard computers' time settings every time the ship passes through a time zone, Tim devised a clever solution using the Time and Date Control Panel utility.

In the shipboard logon script, he put something like this:

Control timedate.
cps,,/Z AlaskanStandard Time

This is just an example, of course. I'm not suggesting the New Zealand Navy
is steaming toward the Alaskan coast. Besides, that time zone is well to the
East of where they spend their time. Simply replace "Alaskan Standard Time"
with whichever time zone you want, based on the descriptions you see in the
drop-down box when you're manually adjusting the time zone through this Control
Panel utility.

They're also stored in the registry at: HKEY_LOCAL_MACHINE \SOFTWARE \Microsoft\Windows NT\CurrentVersion\ Time Zones

You can adjust for Daylight Savings Time by going into: HKEY_LOCAL_MACHINE \System \CurrentControlSet\ Control\TimeZoneInformation and setting DisableAutoDatelightTimeSet to 1 or 0 appropriately.

With the log-on script in place, Tim says the shipboard LAN administrators simply change the script as necessary when the ship hits a new time zone. The next time everyone logs on, they get the local time zone and the clock on their workstation updates itself accordingly. No more missed meals.

This could also be a great way to manage time zones for businesspeople who frequently travel between international corporate offices. By linking the log-on script to the local Active Directory site, you can be assured that your computer will always be displaying local time, rather than the time zone you just left.

About the Author

Don Jones is a multiple-year recipient of Microsoft’s MVP Award, and is an Author/Evangelist for video training company Pluralsight. Don is also a co-founder and President of PowerShell.org, a community dedicated to Microsoft’s Windows PowerShell technology. Don has more than two decades of experience in the IT industry, and specializes in the Microsoft business technology platform. He’s the author of more than 50 technology books, an accomplished IT journalist, and a sought-after speaker and instructor at conferences worldwide. Reach Don on Twitter at @concentratedDon, or on Facebook at Facebook.com/ConcentratedDon.