Guide › How your devices know the time

How your devices know the time

A phone has no pendulum and no caesium. Where its time comes from, how the network hands it over in milliseconds, and why the time zone is a file that keeps…

The quartz in your pocket

A quartz clock counts the vibrations of a crystal, and a crystal is a good but not perfect resonator. Left alone, the oscillator in a phone drifts by seconds a month, and a cheap watch may lose or gain that much in a week. Two unsynced devices therefore drift apart, slowly and then quickly, until a schedule built on them stops making sense.

That is the reason almost everything connected asks what time it is rather than deciding for itself. The crystal is good enough to keep time between two corrections, and not remotely good enough to define it.

Asking the network

The usual protocol is NTP. A device sends a request and notes when it left, the server answers with its own clock, and the device notes when the reply arrived. Half the round trip is a fair estimate of the delay, so the device can work out how far its own clock is off and step it, or slew it gradually if the correction is small. Servers are arranged in layers, or strata, each synced from one above until the chain reaches an atomic clock.

Satellite navigation does the same job differently. Each GPS satellite carries atomic clocks and broadcasts the time continuously; a receiver measures how long each signal took to arrive, and from four of them solves both position and time. A phone with no signal can still be within a second, because a device that has been corrected once keeps counting on its own crystal afterwards.

When the network is gone

Offline, the device runs on its oscillator and a battery-backed real-time clock, and drift resumes. A laptop left in a drawer for two months can come back minutes out, which is why it usually corrects itself before showing you a page. A device with no battery keeps nothing, and starts from whatever the last known time was thought to be.

This is worth remembering when a clock looks wrong in only one place. If the same page shows the correct time on one device and the wrong time on another, the difference is more likely to be the device than the page.

The time zone is not arithmetic

The offset a place keeps cannot be calculated from its longitude, because it is a political decision, and those decisions are collected in a shared database that ships with operating systems and browsers. It is revised several times a year, whenever a government announces a change, and each revision has a version number.

A country can therefore decide in March to move its clock in June, and the change will not exist on a device whose software has not been updated since February. Old phones are the classic example: they show a perfectly correct clock with an outdated offset underneath it.

What happens in the browser here

Every time and date on this site is calculated with the browser's own time zone data, through the standard internationalisation interface. Nothing is fetched from a server and no copy of the rules is stored, so a page is exactly as current as the device that opened it, and it works with no connection at all.

The practical consequence cuts both ways. If the hours here are wrong, so is the device; if a country has changed its rules and the times still look old, the browser is the thing to update. The numbers on these pages are not this site's opinion about the offsets, they are the ones the operating system was last told.

Ogni ora è calcolata in tempo reale e segue le regole dell’ora legale di ciascuna città.