Epoch Milliseconds vs Seconds: Why 10 vs 13 Digits Breaks Your Timestamps
Learn how mixing 10-digit Unix timestamps (seconds) and 13-digit timestamps (milliseconds) breaks dates in JavaScript, Python, and SQL databases.
Standard Unix timestamps count seconds (10 digits, ~1.7 billion in the 2020s), whereas JavaScript's Date object and Java expect milliseconds (13 digits). Passing a 10-digit second timestamp into new Date(1730000000) results in January 1970 because the engine interprets the seconds as milliseconds.
Solve this problem now with our free Epoch / Unix Timestamp Converter
Try it instantly in your browser — zero tracking, 100% client-side privacy.
Specification & Architecture Reference
| Format | Digit Length | Example Timestamp | Interpreted Date |
|---|---|---|---|
| Seconds (Unix/POSIX) | 10 digits | 1729486800 | |
| Milliseconds (JS/Java) | 13 digits | 1729486800000 | |
| Seconds passed to new Date() | 10 digits mistakenly | new Date(1729486800) | |
| Microseconds (Postgres/Go) | 16 digits | 1729486800000000 |
The Anatomy of the 1970 Bug
Unix time is defined by POSIX standards as the number of elapsed seconds since the **Unix Epoch**: midnight UTC on **January 1, 1970** (`1970-01-01T00:00:00Z`), excluding leap seconds.
Most backend languages (C, Python, PHP, Ruby, Go) return timestamps in seconds: ```python import time print(int(time.time())) # e.g. 1729486800 (10 digits) ```
JavaScript, however, was designed to align with Java: `Date.now()` and `new Date(value)` expect the value in **milliseconds** (13 digits): ```javascript console.log(Date.now()); // e.g. 1729486800000 (13 digits) ```
When a developer unknowingly passes a backend 10-digit timestamp directly to `new Date()`: ```javascript const created = new Date(1729486800); console.log(created.toISOString()); // Outputs: 1970-01-21T00:24:46.800Z! ``` Because 1.7 billion milliseconds is only ~20 days, the date resolves to January 1970.
Defensive Parsing in Frontend Code To build resilient timestamp parsers that automatically normalize 10-digit and 13-digit inputs:
function parseEpochSafely(timestamp) {
const num = Number(timestamp);
if (isNaN(num)) return null;
// If the number is under 100 billion, it's in seconds
const ms = num < 100000000000 ? num * 1000 : num;
return new Date(ms);
}Use Mickytool's **Epoch / Unix Timestamp Converter** to paste any 10-digit or 13-digit number and instantly convert it across time zones and formats.
Solve this problem now with our free Epoch / Unix Timestamp Converter
Execute this workflow immediately without saving data on remote servers.
Frequently Asked Questions
When will Unix timestamps reach 11 digits?
A 10-digit timestamp reaches 9,999,999,999 in the year 2286 AD. Until then, second-based epoch timestamps remain 10 digits.
Does Postgres extract(epoch from now()) return seconds or milliseconds?
PostgreSQL's extract(epoch from ...) returns seconds as a floating-point number with microsecond fractions (e.g., 1729486800.123456).