Why computers count from 1 January 1970
Unix epoch time (or POSIX time) counts the number of seconds elapsed since midnight UTC on 1 January 1970. The date was chosen by the early Unix developers at Bell Labs — it was simply "a recent, round date" at the time the system was designed, in the late 1960s.
A Unix timestamp is timezone-independent: 1715000000 means the same absolute instant everywhere on Earth. Converting to a local clock time requires knowing the observer's timezone offset.
Seconds vs milliseconds: the most common confusion
Nearly every language runtime has its own convention:
| Platform | Resolution | Example |
|---|---|---|
| Unix time(), Python time.time() | Seconds | 1715000000 |
| JavaScript Date.now() | Milliseconds | 1715000000000 |
| Java System.currentTimeMillis() | Milliseconds | 1715000000000 |
| Python datetime microseconds | Microseconds | 1715000000000000 |
The easiest way to tell: a 10-digit timestamp is seconds; 13 digits is milliseconds. The tool auto-detects values ≥ 10¹² as milliseconds.
ISO 8601: the portable date format
When storing or transmitting timestamps as strings, use ISO 8601: 2024-05-07T10:30:00Z. The trailing Z means UTC. With offset: 2024-05-07T10:30:00+05:30 for IST.
Why ISO 8601 and not 07/05/2024? Because "07/05/2024" is ambiguous — the US reads it as July 5th, most of the world reads it as May 7th. ISO 8601 is sortable lexicographically, unambiguous, and machine-readable.
The Year 2038 Problem
A 32-bit signed integer can store values from −2,147,483,648 to 2,147,483,647. Unix time 2,147,483,647 falls on 03:14:07 UTC, 19 January 2038.
At that moment, any system still using 32-bit signed integer timestamps will overflow to a large negative number, causing dates to appear as 1901. This affects embedded systems, older databases, and legacy C code using time_t as int32.
Modern 64-bit systems use 64-bit integers for timestamps, extending the representable range to the year 292 billion — there is no practical concern for any software written since the early 2000s.
Timezone arithmetic
A Unix timestamp is always UTC. Adding the timezone offset gives local wall-clock time. India Standard Time (IST) is UTC+5:30 — so UTC 10:00:00 is IST 15:30:00.
Daylight Saving Time (DST) makes this more complicated: the offset changes twice a year. The IANA timezone database (used by every browser and most runtimes) tracks the full history of DST transitions for every timezone. Always store timestamps in UTC and convert to local time only at display time.
Relative time and the UX of timestamps
Raw timestamps like 2024-05-07T10:30:00Z are opaque to most users. Relative times like "3 hours ago" or "in 2 days" are immediately intuitive. The standard is to show relative time for events within the last week, then switch to the absolute date for older items.
Libraries like date-fns, dayjs, and the native Intl.RelativeTimeFormat API handle this formatting correctly across languages.