Date & Time
Unix Timestamp Explained
Understand Unix timestamps, conversion, seconds vs milliseconds, and timezone handling.
A Unix timestamp counts seconds since January 1, 1970 00:00:00 UTC (the Epoch). It's a universal way to represent time.
Why Use Timestamps?
- Timezone-independent: Same moment everywhere
- Easy arithmetic: Subtract to get differences, add for offsets
- Compact: Just a number
- Monotonic: Always increases
Seconds vs Milliseconds
Original Unix counts seconds (10 digits). JavaScript uses milliseconds (13 digits). If your date shows "1970" or year "51384", you have a seconds/milliseconds mismatch.
The Year 2038 Problem
On Jan 19, 2038, 32-bit signed timestamps overflow. Modern systems use 64-bit timestamps (safe for billions of years).
Common Formats
ISO 8601: 2026-09-01T12:00:00Z — recommended for APIs. RFC 2822: Tue, 01 Sep 2026 12:00:00 +0000 — used in email.
Frequently Asked Questions
How to get current timestamp?
JS: Math.floor(Date.now()/1000). Python: int(time.time()). Shell: date +%s.
Why does my JS date show 1970?
JS Date uses milliseconds. Multiply seconds by 1000: new Date(timestamp * 1000).
Are timestamps timezone-dependent?
No. A timestamp is the same moment worldwide. Timezone only matters for display.
