Unix Timestamps: Seconds Since 1970
A Unix timestamp is the number of seconds that have elapsed since January 1, 1970, 00:00:00 UTC (the "Unix epoch"). It's how most systems store and transmit time — a single integer that means the same thing everywhere, regardless of timezone.
Why Timestamps?
Human dates are messy: timezones, daylight saving, date formats (MM/DD vs DD/MM), leap seconds. A Unix timestamp avoids all of this — it's one number, always UTC, universally understood by every programming language.
Converting Timestamps
// JavaScript
new Date(1714000000 * 1000) // timestamps are seconds, JS uses milliseconds
// 2024-04-25T03:06:40.000Z
Date.now() / 1000 // current timestamp in seconds
Math.floor(Date.now() / 1000)
// Create timestamp from date
new Date('2024-04-25').getTime() / 1000 // 1713999600# Python
import datetime
datetime.datetime.fromtimestamp(1714000000)
# datetime(2024, 4, 25, 3, 6, 40)
datetime.datetime.now().timestamp()
# current timestamp# Terminal
date +%s # current timestamp
date -d @1714000000 # convert to date (Linux)
date -r 1714000000 # convert to date (macOS)Common Timestamp Gotchas
| Issue | Cause | Fix |
|---|---|---|
| Date shows 1970 | Timestamp is 0 or null | Check for missing/default values |
| Date is 50 years off | Using milliseconds instead of seconds (or vice versa) | Divide by 1000 (JS→Unix) or multiply by 1000 (Unix→JS) |
| Wrong timezone | Using local time instead of UTC | Always store/compare in UTC, convert for display only |
| Negative timestamp | Date before 1970-01-01 | Perfectly valid — 1969 is timestamp -86400 |
The Year 2038 Problem
32-bit signed integers overflow on January 19, 2038 at 03:14:07 UTC. The max value is 2,147,483,647 seconds. After that, the timestamp wraps to a negative number — back to 1901. Modern systems use 64-bit timestamps, which won't overflow for 292 billion years.
Seconds vs Milliseconds
| Language/System | Unit | Example |
|---|---|---|
| Unix/Linux, Python, PHP, Ruby, Go | Seconds | 1714000000 |
| JavaScript, Java | Milliseconds | 1714000000000 |
| Snowflake IDs (Discord, Twitter) | Custom epoch + ms | Different base epoch |
Convert timestamps now: Unix Timestamp Converter — paste any timestamp or date, get instant conversion in both directions.