Up until now we've only considered time in relation to the machine we're using.

This is only useful for recording events in the vicinity of that machine.

To coordinate events happening elsewhere in the world such as it being midday at Greenwich observatory, it is necessary to synchronise clocks.

We've briefly introduced these concepts in our introduction to time, but more detail is warranted.

Real time

"Real time" or "Wall clock time" is the globally coordinated time system, so if the time of an event is recorded in one location the record of that time can be transmitted elsewhere and they can reason about when this was in relation to their own clocks so they can tell how long ago it happened.

This is handled by computers containing a special piece of hardware called a Real-Time Clock which tracks the current time.

Time Zones

Times were historically defined by the position of the sun in the sky, but the sun is in different positions in the sky depending on where you are, so the coordinated time in any given location depends on where you are.

If you pick any particular location for your definition of coordinated time, you need to know the difference in time from that location to elsewhere for people who have used that place for their time base.

Rather than everywhere tracking what time it is, areas pick a common baseline and everyone in that area uses that time. These are called [Time Zones][] and are usually arranged along political lines.

In practice most computers think in terms of the UTC time zone, and use records of what the difference in time is between the local time zone and UTC.

The difference is normally but not exclusively measured in an integral number of hours since that time in UTC.

Indian standard time is 5½ hours after UTC. North Korea's time is 8½ hours after UTC.

Time zones don't remain fixed. They are political entities so change on political decisions.

Most of the western world observes some form of Daylight saving time where the current time zone depends on what day of the year it is.

This means some times do not exist in every time zone since the time zone is not defined for every part of the year.

As a consequence some local times do not exist everywhere in the world, and the local time is a product of an agreed time in one part of the world, where the local time is being measured, and any political decisions.

An extreme example of this is Samoa skipping the 30th December 2011 and jumping from one time zone to another.

For future proofing you would ideally record the coordinates alongside the UTC time so if a time zone's geopolitical boundaries change the local time at those coordinates may be known.


Your computer's RTC will continue to measure time while your computer is off so when you turn it back on the time is mostly correct.

RTCs are not perfect however, they diverge from real time because they measure time slightly faster or slower.

Handily, because computers are networked they can ask each other what the time actually is. The protocol for doing this is called NTP.

Once a computer has determined the correct time it can use adjtimex(2) to either accelerate or slow the clock until correct, or just set the time to what value it should have.

It is preferable to speed or slow the clock to correct the time unless your computer is still early on in the boot process since you are likely to have programs that will get confused if the time changed a huge amount, but if your computer's clock is sufficiently far ahead or behind then it's impractical to accelerate or slow the clock to the correct time.

Linux's interface to the real time is via the CLOCK_REALTIME clock, though CLOCK_REALTIME_COARSE exists if it's more important that the time is retrieved quickly rather than the result is precise.

Now that we've got a globally coordinated notion of time you can coordinate events globally.

Unfortunately humans aren't trained to think in terms of position and UTC so we need a way to translate this into something human readable, which will be the focus of the next article.