Unix Timestamp Formats Explained
A complete reference for all Unix timestamp formats — seconds, milliseconds, microseconds, ISO 8601, and RFC 2822 — with examples showing which format each language and database uses.
Unix time in seconds — the universal format
The most common format: a 32-bit or 64-bit integer counting the number of whole seconds since January 1, 1970 00:00:00 UTC. Currently a 10-digit number around 1.7 billion.
- Example: 1700000000 = 2023-11-15 06:13:20 UTC
- Used by: Python time.time(), PHP time(), Go time.Now().Unix(), Ruby Time.now.to_i, C time(NULL)
- Stored as: 32-bit int (legacy, max year 2038), 64-bit int (modern, safe for billions of years)
- Database: MySQL UNIX_TIMESTAMP(), PostgreSQL EXTRACT(EPOCH FROM NOW())::BIGINT
Unix time in milliseconds — JavaScript's format
Milliseconds since the Unix epoch: a 13-digit integer providing millisecond precision. This is the format JavaScript's Date object uses internally.
- Example: 1700000000000 = 2023-11-15 06:13:20.000 UTC
- Used by: JavaScript Date.now(), Java System.currentTimeMillis(), .NET DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
- To convert to seconds: Math.floor(ms / 1000)
- To convert from seconds: seconds * 1000
ISO 8601 — the human-readable standard
ISO 8601 is an international standard for representing dates and times as strings. Unlike Unix timestamps, it is self-describing: the format encodes both the date/time and the timezone offset.
- 2023-11-15T06:13:20Z — UTC (the Z suffix means UTC)
- 2023-11-15T01:13:20-05:00 — with explicit UTC offset (EST)
- 2023-11-15T06:13:20.000Z — with milliseconds
- JavaScript: date.toISOString() always returns UTC with Z suffix
- Python: datetime.isoformat(), Go: time.Format(time.RFC3339)
RFC 2822 — email and HTTP date format
RFC 2822 (also called RFC 1123 for HTTP) is the date format used in email headers and HTTP responses. JavaScript's Date.toUTCString() returns this format.
- Example: Wed, 15 Nov 2023 06:13:20 GMT
- Used in: HTTP response headers (Last-Modified, Date, Expires), email headers (Date:)
- JavaScript: date.toUTCString()
- Less common in modern APIs but still widely encountered in web infrastructure
How to detect the timestamp format
When you receive an unknown timestamp value, use these rules to identify its format:
- 10 digits, starts with 1 → Unix seconds (e.g. 1700000000)
- 13 digits, starts with 1 → Unix milliseconds (e.g. 1700000000000)
- Negative → Unix seconds or milliseconds before 1970
- Contains T or Z → ISO 8601 (e.g. 2023-11-15T06:13:20Z)
- Contains a comma or weekday name → RFC 2822 (e.g. Wed, 15 Nov 2023 ...)
- 16 digits → microseconds (divide by 1,000,000 for seconds)
- 19 digits → nanoseconds (divide by 1,000,000,000 for seconds)
Microseconds and nanoseconds
Some high-precision systems use units smaller than milliseconds. These are rare in application-level code but appear in low-level systems, database internals, and observability tools.
- Microseconds (µs): 16-digit integer — Rust SystemTime as_micros(), PostgreSQL clock_gettime()
- Nanoseconds (ns): 19-digit integer — Go time.Now().UnixNano(), Rust SystemTime as_nanos()
- PostgreSQL EXTRACT(EPOCH) returns a floating-point number with microseconds as the fractional part
- To convert nanoseconds to seconds: divide by 1,000,000,000 (1e9)
Unix timestamp formats FAQ
- How many digits is a Unix timestamp?
- A modern Unix timestamp in seconds is 10 digits (around 1.7 billion); in milliseconds it is 13 digits. Microseconds are 16 digits and nanoseconds are 19 digits.
- What is the difference between Unix time and ISO 8601?
- Unix time is a single number of seconds or milliseconds since 1970 UTC and carries no timezone. ISO 8601 is a self-describing string like 2023-11-15T06:13:20Z that encodes the date, time, and offset.
- How do I detect whether a timestamp is seconds or milliseconds?
- Count the digits: a 10-digit value is seconds, a 13-digit value is milliseconds. If a value converts to a date near 1970 or far in the future, the unit was misread.
Timestamp format converters
Convert between Unix time and the platform-specific timestamp formats you meet in the wild: