Unix Time

Overview: Unix timestamps...

The Starting Reference Point: The Unix Epoch

The January 1, 1970, 00:00:00 UTC date is also referred to as the Unix epoch (or POSIX time). Unix timestamps represent the seconds that have elapsed since this date. The Unix timestamp 0 corresponds exactly to this date. For example, the Unix timestamp 123456 represents a point in time that is 123456 seconds after January 1, 1970, 00:00:00 UTC. Although Unix timestamps are widely used across various domains, they continue to be named in recognition of their origin in Unix and Unix-like systems. Initially, Unix systems did not adopt January 1, 1970 as the starting reference point; it was decided arbitrarily by core developers in the early 1970s.

Independence from Timezones

Unix timestamps linearly track seconds since the Unix epoch, making them independent of timezones. This significant advantage facilitates the comparison of timestamps from different computer/software systems worldwide. However, when converting a timestamp to a human-readable date, most converters or software libraries present the human-readable timestamp formatted according to the user's timezone.

Epochalypse: The Year 2038 Problem

Some systems, particularly embedded systems, still utilize signed 32-bit integers to manage and store Unix timestamps. One second after the epoch at 03:14:07 UTC on January 19, 2038, these 32-bit integers will overflow, potentially leading to critical errors.

Leap seconds

Leap seconds are added to Coordinated Universal Time (UTC) to compensate for the gradual slowing of the Earth's rotation, ensuring that UTC remains aligned with solar time. UTC leap seconds are irregular and unpredictable. Leap seconds were introduced in 1972, and since then, 27 leap seconds have been added to UTC. However, the number of seconds per day in Unix timestamps is fixed, and it cannot represent leap seconds.

Simple calculations

Performing arithmetic operations with Unix timstamps is very easy and straighforward.

Example:
Timestamp_1: 1691761435 (2023-08-11T13:43:55.000Z)
Timestamp_2: 1281311297 (2010-08-08T23:48:17.000Z)

Calculate time difference between those two timestamps:
Timestamp_1-Timestamp_2 = 1691761435-1281311297 = 410.450.138 seconds.
410.450.138 seconds = 13.01 years
Please note that timestamps before January 1, 1970, 00:00:00 UTC are represented by a negative number.