Unix timestamps explained: epoch time, seconds vs milliseconds
A Unix timestamp is just a number: the count of seconds since a fixed moment in 1970. That simplicity makes it the default way to store and compare time in code — until the units trip you up.
What "epoch" means
The Unix epoch is 00:00:00 UTC on 1 January 1970. A Unix timestamp is the number of seconds elapsed since then. 1700000000, for example, is a moment in November 2023.
Because it is a single UTC number, timestamps are unambiguous and trivial to sort and subtract. Convert to and from human dates in the Timestamp Converter.
Seconds vs milliseconds — the classic bug
Unix time is in seconds. JavaScript’s Date.now() returns milliseconds. Mixing them is the single most common timestamp bug — your dates land in 1970 or thousands of years in the future.
Date.now() // 1700000000000 (ms)
Math.floor(Date.now()/1000) // 1700000000 (s)
new Date(unixSeconds * 1000) // seconds -> DateTimestamps are UTC
A Unix timestamp carries no timezone — it is always UTC. Timezones are a *display* concern: convert to local time only when showing a date to a user, and store the raw timestamp.
The year 2038 problem
Systems that store the timestamp as a signed 32-bit integer overflow on 19 January 2038. Modern languages use 64-bit integers, which push the limit billions of years out — but legacy systems and databases can still be affected.
Frequently asked questions
- Is a Unix timestamp in seconds or milliseconds?
- The original Unix timestamp is in seconds. Many languages (notably JavaScript) work in milliseconds, so always confirm the unit — a 10-digit value is seconds, 13-digit is milliseconds.
- Do Unix timestamps have a timezone?
- No. They are always UTC. Convert to a local timezone only for display; store the raw UTC value.
- What is the year 2038 problem?
- Timestamps stored as signed 32-bit integers overflow on 19 Jan 2038. 64-bit storage avoids it, but legacy systems may still break.
- How do I convert a timestamp to a date in JavaScript?
- Multiply seconds by 1000 and pass to Date: new Date(unixSeconds * 1000). If you already have milliseconds, pass them directly.
Try it yourself
Put this guide into practice — these tools run free in your browser.