You're reading through an API response, a database record, or a log file, and you see something like 1735430400. That's a Unix timestamp — the number of seconds that have elapsed since midnight on January 1, 1970 (UTC). It's the near-universal standard for representing moments in time in software systems, and knowing how to work with them quickly is a daily developer skill.
Convert any Unix timestamp instantly with the DevToolShack Unix Timestamp Converter — paste a timestamp, see the human-readable date, or pick a date and get the timestamp. Free, no sign-up.
Why Unix Time?
Storing dates as a single integer has several advantages over formatted date strings:
- No timezone ambiguity — a Unix timestamp is always UTC. No guessing whether "2025-01-01 00:00:00" is local time or UTC.
- Simple arithmetic — "7 days from now" is just
timestamp + (7 * 24 * 60 * 60). No date library needed. - Efficient storage — a 32-bit or 64-bit integer takes less space than a formatted string.
- Language-agnostic — every programming language can read and write Unix timestamps without format negotiation.
Seconds vs Milliseconds: The #1 Gotcha
This trips up developers constantly. Unix timestamps traditionally count seconds since the epoch — but JavaScript's Date.now() returns milliseconds. Many modern APIs and databases also use milliseconds.
| Format | Example value (Jan 2025) | Digit count |
|---|---|---|
| Unix seconds | 1735689600 | 10 digits |
| Unix milliseconds | 1735689600000 | 13 digits |
A quick way to tell: if the number has 13 digits, it's milliseconds. If 10, it's seconds. If you pass a millisecond timestamp to code expecting seconds, you'll get a date in the year 57,000-something — a memorable bug.
Working With Timestamps in Code
JavaScript
// Current timestamp in seconds
const nowSeconds = Math.floor(Date.now() / 1000);
// Current timestamp in milliseconds (JS native)
const nowMs = Date.now();
// Convert timestamp (seconds) to Date object
const date = new Date(1735689600 * 1000); // multiply by 1000!
// Convert Date to Unix seconds
const timestamp = Math.floor(new Date('2025-01-01').getTime() / 1000);
// Format a timestamp to readable string
const readable = new Date(1735689600 * 1000).toISOString();
// "2025-01-01T00:00:00.000Z"
Python
import time
from datetime import datetime, timezone
# Current timestamp in seconds
now_seconds = int(time.time())
# Convert timestamp to datetime (UTC)
dt = datetime.fromtimestamp(1735689600, tz=timezone.utc)
# datetime(2025, 1, 1, 0, 0, tzinfo=timezone.utc)
# Convert datetime to timestamp
timestamp = int(datetime(2025, 1, 1, tzinfo=timezone.utc).timestamp())
SQL
-- MySQL: convert Unix timestamp to datetime
SELECT FROM_UNIXTIME(1735689600);
-- MySQL: get current Unix timestamp
SELECT UNIX_TIMESTAMP();
-- PostgreSQL: convert timestamp to datetime
SELECT to_timestamp(1735689600);
-- PostgreSQL: current Unix timestamp
SELECT extract(epoch FROM now())::bigint;
The Year 2038 Problem
32-bit signed integers max out at 2,147,483,647 — which corresponds to January 19, 2038. Systems still using 32-bit Unix timestamps will overflow on that date (similar to Y2K). Modern systems use 64-bit integers, which won't overflow for approximately 292 billion years — not an immediate concern.
If you're working with legacy systems or embedded devices, this is worth being aware of. Most modern databases, languages, and operating systems already use 64-bit time representations.
ISO 8601: The String Alternative
When you need a human-readable timestamp in a string format, ISO 8601 is the standard to use — not locale-specific formats like "12/01/2025" which are ambiguous (is that December 1st or January 12th?).
2025-01-01T00:00:00Z ← UTC (Z suffix)
2025-01-01T08:00:00+08:00 ← with timezone offset
2025-01-01 ← date only
ISO 8601 sorts correctly as a string (lexicographic order = chronological order), is unambiguous, and is supported by every modern date parsing library.
exp and iat claims. Pair it with the Timezone Converter for cross-timezone scheduling.