Seconds, milliseconds, microseconds and nanoseconds
Unix time is defined in seconds since 1970-01-01T00:00:00Z (the Unix epoch), but many languages and APIs return sub-second timestamps. For modern dates, you can tell the unit by the number of digits:
| Unit | Digits (current) | Example | Used by |
|---|---|---|---|
| Seconds (s) | 10 | 1700000000 | Unix/Linux, Python, PHP, SQL, JWTs |
| Milliseconds (ms) | 13 | 1700000000000 | JavaScript (Date.now()), Java, browser APIs |
| Microseconds (µs) | 16 | 1700000000000000 | PostgreSQL, BigQuery, C++ chrono |
| Nanoseconds (ns) | 19 | 1700000000000000000 | Go (UnixNano), Rust, Prometheus/OTel |
Current Unix timestamp in code
| Language / Tool | Seconds | Milliseconds |
|---|---|---|
| JavaScript / TypeScript | Math.floor(Date.now() / 1000) | Date.now() |
| Python | int(time.time()) | int(time.time() * 1000) |
| Bash / macOS / Linux | date +%s | date +%s%3N (GNU) |
| PostgreSQL | EXTRACT(EPOCH FROM NOW())::bigint | (EXTRACT(EPOCH FROM NOW()) * 1000)::bigint |
| Go | time.Now().Unix() | time.Now().UnixMilli() |
Notable epoch milestones
| Timestamp (s) | UTC date & time | Milestone |
|---|---|---|
0 | 1970-01-01T00:00:00Z | The Unix epoch |
946684800 | 2000-01-01T00:00:00Z | Y2K (start of year 2000) |
1000000000 | 2001-09-09T01:46:40Z | 1 billion seconds (billennium) |
1700000000 | 2023-11-14T22:13:20Z | 1.7 billion seconds |
2147483647 | 2038-01-19T03:14:07Z | Signed 32-bit integer limit (Year 2038) |
Working with ordinal day-of-year codes or astronomical Julian Day Numbers instead? Try the Julian date converter. For ISO week numbers, see week number.
Frequently asked questions
What is a Unix timestamp?
A Unix timestamp (also called POSIX time or epoch time) is the number of seconds that have elapsed since 00:00:00 UTC on January 1, 1970, not counting leap seconds.
How do I tell seconds from milliseconds?
Count the digits. For current dates, a Unix timestamp in seconds has 10 digits (e.g. 1700000000), milliseconds has 13 digits, microseconds has 16 digits and nanoseconds has 19 digits. The converter above detects the unit automatically.
Are Unix timestamps always in UTC?
Yes. A Unix timestamp represents a single instant in UTC regardless of where the server or browser is located. Time zones only apply when formatting that instant for human reading.
Can a Unix timestamp be negative?
Yes. Negative timestamps represent dates before January 1, 1970 UTC. For example, -86400 is December 31, 1969 at 00:00:00 UTC.
What is the Year 2038 problem?
Systems that store Unix time as a signed 32-bit integer top out at 2,147,483,647 seconds — Tuesday, January 19, 2038 at 03:14:07 UTC. One second later it overflows. Modern 64-bit systems are unaffected.
How do I get the current Unix timestamp in JavaScript or Python?
In JavaScript use Math.floor(Date.now() / 1000) for seconds (Date.now() returns milliseconds). In Python use int(time.time()).
Sources
- Unix time — Wikipedia
- ISO 8601 — Wikipedia
- Year 2038 problem — Wikipedia
See how we build and test our tools in our editorial policy.