You're reading a server log and you see 1714900000. An API response comes back with "created_at": 1714985600. A database field stores 1715072000000. These are Unix timestamps — and once you understand them, you'll never need to guess again.
What Is a Unix Timestamp?
A Unix timestamp (also called epoch time) is the number of seconds elapsed since January 1, 1970, 00:00:00 UTC. That reference point — January 1st 1970 — is called the Unix epoch.
1714900000 seconds after Jan 1, 1970 = May 5, 2024 09:06:40 UTC
The Unix epoch was chosen when Unix was being designed in the late 1960s. It was a round, convenient number that was far enough in the past to make the timestamps useful immediately.
Seconds vs Milliseconds
Here's where most confusion happens. There are two conventions:
| Format | Length | Example | Range |
|---|---|---|---|
| Seconds (Unix) | 10 digits | 1714900000 | Standard Unix |
| Milliseconds (JavaScript) | 13 digits | 1714900000000 | JS Date.now() |
JavaScript's Date.now() returns milliseconds. Most Unix systems and server-side languages use seconds. If your timestamp is 13 digits, divide by 1000 to get seconds.
// JavaScript — milliseconds
const ms = Date.now(); // 1714900000000
const sec = Math.floor(ms / 1000); // 1714900000
// Convert back
const date = new Date(ms); // works
const date2 = new Date(sec * 1000); // also works
Converting in Different Languages
JavaScript / TypeScript
// Timestamp to date
const ts = 1714900000;
const date = new Date(ts * 1000);
console.log(date.toISOString()); // "2024-05-05T09:06:40.000Z"
console.log(date.toLocaleString()); // local timezone
// Date to timestamp
const now = Math.floor(Date.now() / 1000); // seconds
Python
import datetime
# Timestamp to date
ts = 1714900000
dt = datetime.datetime.fromtimestamp(ts, tz=datetime.timezone.utc)
print(dt.isoformat()) # 2024-05-05T09:06:40+00:00
# Date to timestamp
import time
now_ts = int(time.time())
PHP
// Timestamp to date
$ts = 1714900000;
echo date('Y-m-d H:i:s', $ts); // 2024-05-05 09:06:40
// Date to timestamp
echo time(); // current timestamp
echo strtotime('2024-05-05 09:06:40');
SQL (PostgreSQL)
-- Timestamp to date
SELECT TO_TIMESTAMP(1714900000);
-- 2024-05-05 09:06:40+00
-- Date to timestamp
SELECT EXTRACT(EPOCH FROM NOW())::INTEGER;
SQL (MySQL)
SELECT FROM_UNIXTIME(1714900000);
-- 2024-05-05 09:06:40
SELECT UNIX_TIMESTAMP(NOW());
Time Zones
Unix timestamps are always in UTC. Converting to a local time requires knowing the offset. This is why you'll often see timestamps stored as integers in databases — timezone conversion happens at display time, in the client's local context.
const ts = 1714900000;
const date = new Date(ts * 1000);
// UTC
console.log(date.toUTCString());
// "Sun, 05 May 2024 09:06:40 GMT"
// Local (depends on system timezone)
console.log(date.toLocaleString('en-US', { timeZone: 'America/New_York' }));
// "5/5/2024, 5:06:40 AM"
ISO 8601 vs Unix Timestamp
| Format | Example | Pros | Cons |
|---|---|---|---|
| Unix timestamp | 1714900000 | Compact, easy math, timezone-neutral | Not human-readable |
| ISO 8601 | 2024-05-05T09:06:40Z | Human-readable, standard | Longer, parsing varies |
Use Unix timestamps for storage and comparison (sorting, range queries, time math). Use ISO 8601 for display and APIs (more readable, unambiguous timezone handling with the Z suffix).
The Year 2038 Problem
Unix timestamps stored as 32-bit signed integers will overflow on January 19, 2038 at 03:14:07 UTC. After that point, 32-bit systems will wrap to a large negative number, interpreted as a date in 1901.
Most modern systems use 64-bit integers for timestamps, which extends the range to the year 292 billion. If you're building new systems, use 64-bit. If you're maintaining old C or embedded code, this is worth auditing.
Convert Any Timestamp Instantly
Use our Unix Timestamp Converter to decode any timestamp to local time, UTC, ISO 8601, and relative ("3 days ago"). Live clock always shown. Convert dates back to timestamps. No page reload required.