What Does the System Clock Represent?
The system clock holds the computer's current date and time, counted from an epoch. See what it tracks, what keeps it accurate, and why it can run backwards.
The system clock represents the computer's best answer to what time is it right now in the real world — a date and time of day, usually stored as a count of seconds or nanoseconds since a fixed epoch.
On Unix-like systems that epoch is 1 January 1970 UTC, and the count is the [Unix timestamp](/blog/unix-timestamp-explained).
What It Is Made Of
Three pieces have to cooperate:
- The RTC — a battery-backed real-time clock chip on the motherboard that keeps counting while the machine is off. It is cheap and drifts, typically by seconds per week.
- The system clock — a value the operating system keeps in memory, initialised from the RTC at boot and advanced by the kernel from then on.
- NTP — a network service that corrects the system clock against reference servers, typically to within a few milliseconds.
At boot, the OS reads the RTC. Once networking is up, NTP corrects it. The corrected value is what every application sees.
It Can Move Backwards
This is the property that matters most and surprises people most. The system clock is not monotonic. It can jump:
- Backwards, when NTP finds it running fast
- Forwards, when NTP finds it slow, or when a laptop wakes from sleep
- Sideways, when the time zone or DST offset changes
So a duration measured by subtracting two system-clock readings can come out negative, or wildly wrong, through no fault of the code.
Which Clock to Use for What
| Purpose | Clock |
|---|---|
| Log timestamps, file dates, calendar events | System clock (wall clock) |
| Measuring how long something took | Monotonic clock |
| Scheduling "in 5 minutes" | Monotonic clock |
| Scheduling "at 09:00 tomorrow" | System clock |
The monotonic clock only ever moves forward at a steady rate and has no relationship to calendar time — it cannot tell you the date, but it cannot lie about elapsed time either. See [what is a monotonic clock](/blog/what-is-a-monotonic-clock).
Time Zones Are Not Part of It
The system clock almost always holds UTC. Your local time is that value plus an offset applied at display time, from the IANA time zone database. Changing your time zone does not change the system clock; it changes how the same number is rendered. That is why a Unix timestamp is the same everywhere and [has no time zone of its own](/blog/unix-timezone-conversion).
Why It Goes Wrong
A dead RTC battery, a machine with no network access, a dual-boot setup where one OS writes local time to the RTC and the other expects UTC — all produce a system clock that is confidently wrong. [Why is my computer clock wrong](/blog/why-is-my-computer-clock-wrong) covers the usual causes.