A Unix timestamp (also called epoch time) is the number of seconds that have elapsed since 00:00:00 UTC on January 1, 1970 — the Unix epoch. It is the universal language for storing and comparing points in time in software systems.
Why Epoch Time?
- Time zone independent. A Unix timestamp represents the same instant everywhere on Earth. Display it in any timezone later.
- Simple arithmetic. Subtract two timestamps to get duration in seconds. Compare them with a single integer comparison.
- Compact. A 32-bit integer can represent dates across 136 years. A 64-bit integer handles billions of years.
- Universal. Every programming language and database supports Unix timestamps natively.
Getting the Current Timestamp
Math.floor(Date.now() / 1000)import time; int(time.time())date +%stime.Now().Unix()SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs()EXTRACT(EPOCH FROM NOW())::BIGINTUNIX_TIMESTAMP()Converting a Timestamp to a Date
new Date(timestamp * 1000).toISOString()datetime.utcfromtimestamp(timestamp)time.Unix(timestamp, 0).UTC()DateTime::from_timestamp(timestamp, 0)Note: JavaScript's Date uses milliseconds, not seconds. Multiply by 1000 when converting a Unix timestamp, and divide by 1000 when creating one from Date.now().
Useful Reference Points
| Timestamp | Date (UTC) |
|---|---|
| 0 | Thu Jan 01 1970 00:00:00 |
| 1000000000 | Sat Sep 09 2001 01:46:40 |
| 1234567890 | Fri Feb 13 2009 23:31:30 |
| 1700000000 | Wed Nov 15 2023 00:13:20 |
| 2000000000 | Wed May 18 2033 03:33:20 |
| 2147483647 | Tue Jan 19 2038 03:14:07 (max 32-bit) |
The Year 2038 Problem (Y2K38)
32-bit signed integers overflow on January 19, 2038 at 03:14:07 UTC (timestamp 2147483647). Systems storing timestamps in int32 will wrap to a negative number, representing dates in 1901. The fix is to use 64-bit integers — which can represent dates hundreds of billions of years into the future. Most modern systems already use 64-bit timestamps.
Convert between Unix timestamps and human-readable dates with the Unix Timestamp Converter tool.