Unix epoch, date formats, timezone offsets, and ready-to-use code snippets for every language.
0
1970-01-01T00:00:00Z
946684800
2000-01-01T00:00:00Z
2147483647
2038-01-19T03:14:07Z β max for 32-bit signed int
9223372036854775807
~292 billion years β no practical overflow
86400000
60 Γ 60 Γ 24 Γ 1000
31536000
365 Γ 24 Γ 60 Γ 60 (non-leap)
2024-01-15T12:30:00Z
YYYY-MM-DDTHH:MM:SSZ β widely recommended
2024-01-15T07:30:00-05:00
YYYY-MM-DDTHH:MM:SSΒ±HH:MM
Mon, 15 Jan 2024 12:30:00 +0000
Used in email headers and HTTP headers
2024-01-15T12:30:00.000Z
Subset of ISO 8601 with milliseconds
Mon, 15 Jan 2024 12:30:00 GMT
Used in HTTP headers (Last-Modified, Date)
01/15/2024
Ambiguous β avoid in APIs
15/01/2024
Ambiguous β avoid in APIs
2024-01-15
SQL DATE type, BigQuery, Redshift
20240115123000
Lexicographically sortable
Date.now()
Returns milliseconds since epoch
Math.floor(Date.now() / 1000)
Returns whole seconds
new Date(ts * 1000).toISOString()
Multiply by 1000 if ts is in seconds
Math.floor(new Date('2024-01-15T12:30:00Z').getTime() / 1000)import time; time.time()
Returns float with sub-second precision
from datetime import datetime, timezone datetime.fromtimestamp(ts, tz=timezone.utc)
Always pass tz=timezone.utc to avoid local timezone
from datetime import datetime, timezone
datetime.fromisoformat('2024-01-15T12:30:00+00:00').timestamp()SELECT EXTRACT(EPOCH FROM NOW())::BIGINT;
Returns whole seconds
SELECT to_timestamp(1705319400);
SELECT UNIX_TIMESTAMP();
SELECT FROM_UNIXTIME(1705319400);
time.Now().UnixNano()
Nanoseconds precision
time.Now().Unix()
SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs()
time()
Returns seconds; microtime(true) for float
date +%s
GNU/BSD date; on macOS same command works
+00:00
Coordinated Universal Time β no DST
-05:00 / -04:00
EST in winter, EDT in summer (DST)
-06:00 / -05:00
-07:00 / -06:00
-08:00 / -07:00
+00:00 / +01:00
BST (British Summer Time) in summer
+01:00 / +02:00
Germany, France, Italy, Poland, etc.
+05:30
No DST β half-hour offset
+08:00
No DST β entire country one timezone
+09:00
No DST
+10:00 / +11:00
DST in southern hemisphere summer (OctβApr)
+12:00 / +13:00
| Unit | Digits | Example | Range approx. |
|---|---|---|---|
| Seconds (s) | 10 | 1705319400 | 1970 β 2286 |
| Milliseconds (ms) | 13 | 1705319400000 | 1970 β 2286 (Γ1000) |
| Microseconds (ΞΌs) | 16 | 1705319400000000 | Sub-second precision |
| Nanoseconds (ns) | 19 | 1705319400000000000 | Used by Go, Rust, Linux kernel |
A Unix timestamp (also called epoch time) is the number of seconds elapsed since 00:00:00 UTC on January 1, 1970, not counting leap seconds. It is a single integer that unambiguously identifies any moment in time, independent of timezone.
Traditional Unix timestamps count whole seconds. Modern languages and APIs (JavaScript Date.now(), Java System.currentTimeMillis()) use milliseconds β 1000Γ larger β for sub-second precision. When interoperating, always check the magnitude: a 10-digit number is seconds, a 13-digit number is milliseconds.
32-bit signed integers can represent timestamps up to 2,147,483,647, which corresponds to 03:14:07 UTC on January 19, 2038. After that moment 32-bit systems will overflow to negative values. 64-bit systems can safely represent dates well beyond the year 292 billion.
In JavaScript: new Date(ts * 1000).toISOString(). In Python: datetime.fromtimestamp(ts, tz=timezone.utc).isoformat(). In SQL (PostgreSQL): to_timestamp(ts). ISO 8601 format is YYYY-MM-DDTHH:MM:SSZ for UTC, e.g. 2024-01-15T12:30:00Z.