Unix Timestamp & POSIX Epoch Time Guide: Seconds, Milliseconds & Y2K38
Understand how Unix epoch time counts seconds since January 1, 1970 UTC, spot 10-digit vs. 13-digit timestamps, handle leap seconds and time zones, and prepare for the Year 2038 32-bit overflow.
What Is a Unix Timestamp (Epoch Time)?
A Unix timestamp (also called Epoch time or POSIX time) is a single integer tracking the elapsed seconds since 00:00:00 Coordinated Universal Time (UTC) on Thursday, January 1, 1970—known as the Unix Epoch.
Instead of storing localized strings such as "Nov 20, 2026 3:45 PM EST", databases, APIs, JWT tokens, and distributed logs store one timezone-independent integer that sorts chronologically and subtracts cleanly. Convert any human date or raw integer immediately with our Unix Epoch Timestamp Converter, or inspect human time conversions in our Time Unit Converter and World Time Zone Converter.
Why Every Unix Timestamp Is Always UTC
A raw Unix timestamp carries zero timezone offset: 1767225600 occurs at the exact same physical instant worldwide (2026-01-01T00:00:00Z), even though Tokyo (UTC+9) sees 09:00 morning and New York (UTC−5) sees 19:00 on December 31, 2025.
Digit-Length Precision: Seconds vs. Milliseconds vs. Nanoseconds
One of the fastest ways to debug API payload errors is recognizing timestamp scale purely by digit count around the 2020s–2030s:
| Precision Unit | Multiplier | Typical Digits | Common Languages & Systems |
|---|---|---|---|
| Seconds (s) | 1 s | 10 digits (~1.7 × 10⁹) | POSIX time_t, PHP, Go Unix(), JWT exp |
| Milliseconds (ms) | 10⁻³ s | 13 digits (~1.7 × 10¹²) | JavaScript Date.now(), Java System.currentTimeMillis() |
| Microseconds (µs) | 10⁻⁶ s | 16 digits (~1.7 × 10¹⁵) | PostgreSQL, BigQuery, Chrome performance logs |
| Nanoseconds (ns) | 10⁻⁹ s | 19 digits (~1.7 × 10¹⁸) | Go time.Now().UnixNano(), Linux kernel, Kubernetes |
Essential Epoch Time Formulas & Rules
POSIX defines every calendar day as exactly 86,400 seconds (24 × 60 × 60), ignoring UTC leap seconds.
Dividing 1,700,000,000,000 by 1,000 yields 1,700,000,000; forgetting ÷1000 pushes dates past Year 55,000 AD!
Corresponds to Tuesday, January 19, 2038 at 03:14:07 UTC. One second later wraps negative in 32-bit C systems.
How POSIX Handles Leap Days, Leap Seconds & Dates Before 1970
1. Negative Unix Timestamps (Pre-1970 Dates)
Timestamps before 1970-01-01T00:00:00Z are represented as negative integers:
- Moon landing (
1969-07-20T20:17:40Z):−14,182,940seconds. - Note that pre-1970 support depends on signed integer types (
int64_t), since unsigneduint32_tcannot represent negative history.
2. Leap Seconds vs. Leap Years
- Leap Years (such as
2024,2028, divisible by 4, except centuries not divisible by 400): POSIX fully counts February 29 as an extra86,400-second day, keeping calendar dates aligned with Earth’s orbit. - Leap Seconds: Astronomical UTC occasionally inserts an extra second (
23:59:60) to match Earth’s slightly slowing rotation. POSIX standard mandates that every single Unix day still advance by exactly 86,400 seconds—either repeating a timestamp or “smearing” the extra second smoothly across 24 hours (Google/AWS NTP smear), ensuringtimestamp % 86,400 == 0always lands cleanly on midnight UTC.
3. The Year 2038 Overflow Problem (Y2K38)
Legacy 32-bit embedded controllers, older filesystems (ext2/ext3), and legacy MySQL TIMESTAMP columns store Unix seconds in a signed 32-bit integer (int32_t), capped at 2,147,483,647. At 03:14:08 UTC on January 19, 2038, overflowing that signed bit flips the value to −2,147,483,648 (December 13, 1901). Modern 64-bit time_t extends the limit to 292 billion years—over twenty times the age of the universe.
Step-by-Step Worked Examples
Example 1: Finding the Elapsed Time Between Two Epoch Seconds
Suppose an API log shows job start 1,760,000,000 and completion 1,760,219,600:
- Subtract timestamps:
1,760,219,600 − 1,760,000,000 = 219,600seconds. - Whole days:
219,600 ÷ 86,400 = 2days (2 × 86,400 = 172,800 s), remainder46,800seconds. - Whole hours:
46,800 ÷ 3,600 = 13hours (13 × 3,600 = 46,800 s),0minutes. - Result: 2 days and 13 hours (verify complex clock spans anytime in our Time Duration Calculator).
Example 2: Fixing a JavaScript Date(1700000000) Bug
Passing a 10-digit backend Unix timestamp (1700000000) directly into new Date(1700000000) treats it as milliseconds, rendering 1970-01-20T16:13:20Z (only 19 days after 1970!) instead of November 14, 2023. Always multiply 10-digit API seconds by 1,000 inside new Date(sec * 1000).
Common Production Pitfalls
- Passing Seconds to a Millisecond Parser (1970 Date Bug) or passing Milliseconds to a Seconds Parser (
Year 55,000overflow). - DST Jumps When Computing “Tomorrow = Now + 86,400”: Adding
86,400advances exactly 24 physical hours, which during Daylight Saving Time transitions lands at23:00or01:00local time instead of matching wall-clock hour. - Comparing Unix Integers vs. ISO 8601 Strings (
2026-11-20T00:00:00Z): Store integers for compact arithmetic and indexing; expose human-readable ISO 8601 strings in public JSON APIs for instant human readability.
Always Benchmark Systems Past 2038
If your backend calculates 15- or 30-year mortgage schedules or SSL certificate renewals, test timestamps beyond 2,147,483,647 right now to confirm 64-bit timestamp storage across your database schema. Also review our Accuracy & Methodology guide.
Frequently Asked Questions
Why did Unix choose January 1, 1970 as Epoch Zero?
Early Unix engineers at Bell Labs initially defined epoch relative to 1971 in 1/60s ticks inside a 32-bit register; when switching to 1-second increments around 1971–1972, they chose the clean start of the closest round decade: 1970-01-01T00:00:00Z.
Does JavaScript Date.now() suffer from the Year 2038 overflow?
No—JavaScript represents timestamps as IEEE-754 double-precision floating-point milliseconds (Number), safely covering ±285,616 years around 1970 cleanly (±8.64 × 10¹⁵ ms).