Core Tools
Clock Alarm Timer Stopwatch World Clock
Specialty Clocks
Pomodoro ADHD Clock Chess Clock Binary Clock
Style

How Does Your Computer Know What Time It Is?

NTP, atomic clocks, leap seconds, and why your computer's clock is almost certainly accurate to within a fraction of a second โ€” explained simply.

๐Ÿ“– 6 min read ยท Timekeeping

Your Computer Has No Internal Sense of Time

Your computer knows what time it is right now, to the millisecond, even if you've never set it manually. It knows this when you restart it, when you change time zones, and after a power outage. The mechanism behind this is more interesting than most people expect โ€” and it explains why the time on your device is almost always correct while the clock on your microwave probably isn't.

The hardware clock that never stops

Inside almost every computer and phone is a small, separate chip called a real-time clock (RTC). It has its own power supply โ€” typically a tiny coin cell battery โ€” that keeps it running even when the main device is completely off. The RTC oscillates at a fixed frequency, counts those oscillations, and maintains a running tally of the current date and time. When you start your computer, one of the first things the operating system does is read the current time from the RTC.

The problem with the hardware clock is that it drifts. The oscillator isn't perfectly precise, and temperature changes affect it. Over days and weeks, a hardware clock running in isolation will drift by seconds, then minutes. For a microwave, this is fine. For a computer coordinating with servers and other devices worldwide, it isn't.

The Network Time Protocol

The solution is the Network Time Protocol, or NTP. Developed by David Mills in the 1980s, NTP is a system that synchronizes clocks across a network by querying servers that maintain extremely accurate time references. When your device connects to the internet, NTP runs quietly in the background, comparing your system clock to a time server and making tiny adjustments to keep them aligned.

The time servers at the top of the NTP hierarchy โ€” called stratum 0 servers โ€” are connected directly to atomic clocks or GPS receivers, which are among the most accurate time sources available. Your device likely synchronizes with a stratum 2 or stratum 3 server, meaning it's two or three steps removed from the primary source. The accuracy at this distance is typically within a few milliseconds โ€” imperceptibly close to perfect for any practical purpose.

Atomic clocks and why they're so accurate

Atomic clocks measure time based on the oscillations of atoms โ€” typically cesium-133. These oscillations are extraordinarily regular: one second is defined as exactly 9,192,631,770 oscillations of a cesium atom. An atomic clock accurate to this standard would gain or lose less than one second in 300 million years.

The international time standard, UTC (Coordinated Universal Time), is maintained by averaging the output of several hundred atomic clocks distributed across the world. When your phone displays the correct time, that time traces back through NTP servers to these clocks.

GPS as a time source

GPS satellites are, at their core, precision time systems. Each satellite carries multiple atomic clocks and broadcasts a time signal continuously. GPS receivers on the ground โ€” including the one in your smartphone โ€” use these signals primarily to calculate position, but they also receive an extremely precise timestamp in the process. Many time servers use GPS as their primary time source because it provides atomic-clock accuracy without needing a physical connection to a clock.

Why your phone is more accurate than your microwave

Your microwave has a simple oscillator and no connection to any time server. It drifts, and nobody corrects it. Your phone has NTP running automatically, continuously, comparing its clock to multiple servers and correcting for any drift before it becomes noticeable. The clock you see on your phone's home screen reflects a consensus of atomic clocks maintained by institutions around the world, delivered to your device over the internet several times per day.

The next time you wonder what time it is, you can check the online clock โ€” which itself reads the current time from your device's system clock, which got it from NTP, which got it from an atomic clock somewhere in the world. The chain from cesium atom to your screen takes milliseconds and happens without you thinking about it at all.

See the current time tracked to the second in your browser.

Open Clock โ†’