Definition

Unix time (also called POSIX time or epoch time) is the number of seconds that have elapsed since 00:00:00 UTC on 1 January 1970, not counting leap seconds. It is a single integer, independent of timezone, which makes it ideal for storage and comparison.

The epoch itself is arbitrary: it was chosen as a convenient recent date when Unix was designed. Other systems used different epochs (Windows FILETIME starts in 1601, NTP in 1900, Excel in 1899), which is why converting between systems requires an offset.

Why an integer is better than a date string

An integer sorts correctly, compares cheaply, takes eight bytes, and cannot be ambiguous about timezone. A string like 11/12/2025 can mean November 12 or December 11 depending on locale, and a string without an offset cannot identify an instant.

  • Arithmetic is trivial: add 86,400 for the next day (modulo DST caveats).
  • Sorting is numeric, not lexical.
  • No timezone suffix to strip or misparse.
  • Stable across languages and databases.

Leap seconds and why Unix time ignores them

UTC inserts leap seconds to keep atomic time aligned with Earth's rotation. Unix time deliberately ignores them: a day is always 86,400 seconds in Unix time, even when a leap second occurs. This keeps arithmetic predictable but means Unix time can differ from UTC by a few seconds around a leap second.

Most software smears the leap second over a window (Google's leap smear) or repeats a second, so the discrepancy is invisible at human scale but can matter for precise measurement.

Where epoch time breaks

32-bit signed integers overflow at 2,147,483,647 seconds, which is 2038-01-19T03:14:07 UTC. This is the Year 2038 problem. Modern 64-bit systems are fine for billions of years, but embedded devices, old databases, and binary file formats may still store 32-bit timestamps.

Milliseconds stored in a 32-bit integer overflow much sooner — in 1970 plus 24 days. If a legacy system shows dates in early 1970, unit confusion is the likely cause.

When storing timestamps, use 64-bit integers or a native timestamp type, and document the unit in the column name (created_at_ms vs created_at_s).