Unix Timestamps Explained: Converting Epoch Time
What Unix epoch time is, the difference between seconds and milliseconds, how to convert timestamps to human dates, and the Year 2038 problem developers should know.
If you have ever seen a number like 1752566400 stored in a database or returned by an API, you have met a Unix timestamp. It is one of the most common ways computers represent a moment in time, and understanding it saves developers hours of debugging.
What Is Epoch Time?
A Unix timestamp counts the number of seconds that have elapsed since the Unix epoch: 00:00:00 UTC on January 1, 1970. Because it is a single integer in UTC, it is timezone-independent and trivial to store, compare, and sort, which is why it is so popular in databases and APIs.
Seconds vs Milliseconds
This is the most common source of bugs. Unix systems and most backends use seconds, while JavaScript uses milliseconds. A 10-digit number is almost always seconds; a 13-digit number is milliseconds.
// JavaScript works in milliseconds
const nowMs = Date.now(); // e.g. 1752566400000
const nowSeconds = Math.floor(nowMs / 1000);
// Convert a seconds timestamp to a readable date
const date = new Date(1752566400 * 1000);
console.log(date.toISOString());The Year 2038 Problem
Older systems store timestamps in a signed 32-bit integer, which can only count up to 2,147,483,647 seconds. That limit is reached on January 19, 2038, after which the value overflows into negative numbers. Modern systems use 64-bit integers, which push the limit billions of years into the future, but legacy code should be audited.
When debugging time bugs, first confirm whether you are dealing with seconds or milliseconds. That one check resolves the majority of timestamp errors.
To convert any timestamp to a human-readable date (or the reverse) without wiring up code, use the Epoch Converter. It handles both seconds and milliseconds instantly in your browser.