Unix Timestamps Demystified: A Beginner's Guide to Epoch Time
Published: July 8, 2025 · 6 min read
If you've ever looked at an API response and seen something like "created_at": 1718123400, you've encountered a Unix timestamp. That seemingly random 10-digit number is actually a precise moment in time — and once you understand how it works, you'll see why it's the backbone of timekeeping in virtually every operating system, database, and API on the planet.
What Exactly Is a Unix Timestamp?
A Unix timestamp (also called epoch time or POSIX time) is simply the number of seconds that have elapsed since 00:00:00 UTC on January 1, 1970 — a moment known as "the Unix epoch." It's a single integer that represents an absolute point in time, independent of time zones, daylight saving time, or calendar quirks.
That's the genius of it. Instead of dealing with the nightmare complexity of dates (months with different lengths, leap years, time zones, DST transitions), you store one number. Converting that number to a human-readable date is a display concern — the data itself is clean, compact, and unambiguous.
Here's how it looks in practice:
- Timestamp 0 = January 1, 1970, 00:00:00 UTC (the epoch)
- Timestamp 60 = January 1, 1970, 00:01:00 UTC (one minute after the epoch)
- Timestamp 3600 = January 1, 1970, 01:00:00 UTC (one hour after the epoch)
- Timestamp 86400 = January 2, 1970, 00:00:00 UTC (one day after the epoch)
The math is refreshingly simple: add 86,400 for each day, 3,600 for each hour, 60 for each minute.
Why Developers Love Unix Timestamps
Ask any backend developer why they prefer timestamps over formatted date strings, and you'll get a consistent set of answers:
1. Timezone Independence
A timestamp like 1718123400 represents the exact same moment everywhere on Earth. It doesn't matter if your server is in Tokyo, your database is in Frankfurt, and your user is in São Paulo — the timestamp is identical. You only apply a timezone when you display it to a human. This eliminates an entire category of bugs caused by timezone mismatches.
2. Easy Sorting and Comparison
Since timestamps are just integers, comparing them is trivial: timestamp_a > timestamp_b tells you which event happened later. Sorting chronologically is a simple numeric sort. Range queries ("give me all records from the last 24 hours") become basic arithmetic: WHERE created_at > 1718123400 - 86400.
3. Compact Storage
Ten digits (or 4 bytes as a 32-bit integer, 8 bytes as 64-bit) stores a precise second. A formatted date string like "2024-06-11T14:30:00+00:00" takes 25+ bytes. When you're storing billions of records, that difference matters.
4. No Leap Second Chaos
Unix time technically ignores leap seconds. When a leap second occurs, Unix time either repeats a second or smears it, depending on the implementation. This keeps the math clean and predictable.
Timestamps for Famous Dates
Here are some reference timestamps to give you a sense of scale:
- Unix epoch: 0 (January 1, 1970)
- Moon landing: -14182940 (July 20, 1969 — yes, timestamps can be negative for dates before 1970)
- Apple Inc. founded: 208284480 (April 1, 1976)
- Fall of Berlin Wall: 626572800 (November 9, 1989)
- Y2K / Millennium: 946684800 (January 1, 2000)
- iPhone announced: 1181692800 (January 9, 2007)
- Bitcoin genesis block: 1231006505 (January 3, 2009)
- COVID-19 declared pandemic: 1583899200 (March 11, 2020)
Notice how the numbers grow steadily — each passing day adds exactly 86,400. As of July 2025, the current timestamp is roughly 1752280000.
The Year 2038 Problem: A Ticking Clock
If you've heard anything about Unix timestamps, you've probably heard about the Year 2038 problem. Here's what it actually means.
On 32-bit systems, a Unix timestamp is stored as a signed 32-bit integer. The maximum value a signed 32-bit integer can hold is 2,147,483,647. Count that many seconds from January 1, 1970, and you land on 03:14:07 UTC on January 19, 2038. One second later, the counter overflows and wraps around to -2,147,483,648 — which, interpreted as a timestamp, is December 13, 1901. Systems that rely on 32-bit timestamps would suddenly think it's 1901.
This is the same class of problem as Y2K, but with a harder deadline. The good news: most modern systems use 64-bit timestamps, which can represent dates 292 billion years into the future — long after our sun burns out. The bad news: embedded systems, legacy databases, and older file systems still use 32-bit time representations. Think ATMs, aviation systems, industrial controllers — devices that don't get updated often.
If you're writing new code today and storing timestamps as integers, use a 64-bit type (int64, bigint, long) and you'll never have to worry about 2038.
Seconds vs. Milliseconds: Know the Difference
One common source of bugs: some systems use seconds (10-digit timestamps) and others use milliseconds (13-digit timestamps). JavaScript's Date.now() returns milliseconds. Python's time.time() returns seconds as a float. APIs vary. If you pass a second-based timestamp into a function expecting milliseconds, your date will be off by a factor of 1,000 — interpreting January 1970 as the year 52897.
Quick check: if the timestamp is around 1.7 billion, it's seconds. If it's around 1.7 trillion (1,700,000,000,000), it's milliseconds.
Converting Timestamps to Readable Dates
Every programming language has built-in functions for this:
- JavaScript:
new Date(timestamp * 1000)(multiply by 1000 because JS expects milliseconds) - Python:
datetime.fromtimestamp(timestamp, tz=timezone.utc) - PHP:
date('Y-m-d H:i:s', $timestamp) - SQL:
SELECT FROM_UNIXTIME(timestamp)
But for quick one-off conversions without writing code, use our free Timestamp Converter. Paste any timestamp and instantly see the corresponding date and time in your local timezone — or pick a date and get its timestamp. It handles both second and millisecond timestamps automatically.