Leap Seconds vs. POSIX Time

The Earth's rotation is not perfectly constant—it wobbles and slows down. To keep our clocks (UTC) in sync with the sun (UT1), we occasionally add a Leap Second. However, Unix time pretends these seconds simply do not exist.

The POSIX Definition

POSIX standards define a day as exactly 86,400 seconds.

"A value that approximates the number of seconds that have elapsed since the Epoch. [...] As it is an approximation, it allows for leap seconds to be ignored."

This simplifies date math (you can always divide by 86400 to get days), but it creates a problem during the leap second itself.

What Happens at 23:59:60?

When a leap second is added (usually June 30 or Dec 31), the official UTC time goes:

  • 23:59:58
  • 23:59:59
  • 23:59:60 (Leap Second)
  • 00:00:00

But a Unix clock cannot represent :60. So it typically repeats the second:

  • Timestamp X (23:59:59)
  • Timestamp X (23:59:59 again)
  • Timestamp X+1 (00:00:00)

The Solution: Leap Smearing

To avoid crashing software that assumes time strictly moves forward (and to avoid ambiguous timestamps), tech giants like Google and Amazon use Leap Smearing.

Instead of adding one whole second at the end, they run their clocksslightly slower (by 0.0014%) for the 24 hours surrounding the leap event. By the end of the day, they have "drifted" exactly one second, matching UTC again, without ever jumping back or repeating numbers.

Frequently Asked Questions

Does Unix timestamp include leap seconds?

No. POSIX time explicitly ignores leap seconds. Every day in Unix time has exactly 86400 seconds. When a leap second occurs, the system clock might repeat a second.

What is a leap second?

A one-second adjustment applied to Coordinated Universal Time (UTC) to keep it close to mean solar time (UT1). The Earth's rotation is slowing down slightly.

What is Leap Smearing?

A technique used by Google, Amazon, and others where the extra second is effectively "smeared" (added in tiny microseconds) over a 24-hour period, so the clock never jumps or repeats.