Timestamp Formats

Unix Timestamp Formats Explained

A complete reference for Unix timestamp formats — Unix time, epoch time, POSIX timestamp, seconds, milliseconds, microseconds, ISO 8601, and RFC 2822 — with examples showing which format each language and database uses.

Unix time, epoch time, and POSIX timestamp

Unix time, epoch time, POSIX timestamp, and Unix timestamp are usually different names for the same idea: count elapsed seconds from 1970-01-01 00:00:00 UTC. When someone searches timestamp to epoch or timestamp Unix time, they are usually asking whether their value is already a Unix timestamp, which unit it uses, or how to convert a date string into the epoch integer.

  • 10 digits: Unix timestamp seconds, the classic POSIX time_t form
  • 13 digits: Unix milliseconds, common in JavaScript Date and Java
  • A date string such as 2026-06-28T12:00:00Z must be parsed before it can become epoch seconds
  • The reverse direction, epoch to time, turns the integer back into a readable date

Every Unix timestamp format at a glance

A Unix timestamp is just a number, and its format is really just its unit — how finely it counts from January 1, 1970 UTC. The unit is almost always readable from the digit count: 10 digits is seconds, 13 is milliseconds, 16 is microseconds, 19 is nanoseconds. The two string formats, ISO 8601 and RFC 2822, are self-describing instead. The table below is the whole landscape; the sections after it cover each format and how to tell them apart.

FormatDigitsExampleUsed by
Seconds101700000000Python, PHP, Go, Ruby, C, SQL
Milliseconds131700000000000JavaScript, Java, .NET
Microseconds161700000000000000PostgreSQL, Rust
Nanoseconds191700000000000000000Go UnixNano, tracing systems
ISO 8601string2023-11-15T06:13:20ZAPIs, logs (self-describing)
RFC 2822stringWed, 15 Nov 2023 06:13:20 GMTEmail, HTTP headers

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 (updated by RFC 5322 for email, and mirrored by RFC 9110 for HTTP) is the human-readable 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, these rules identify its format. The digit count settles every numeric case; the two string formats are obvious on sight.

ClueFormat
10 digitsUnix seconds
13 digitsUnix milliseconds
16 digitsMicroseconds
19 digitsNanoseconds
Contains T or ZISO 8601
Comma or weekday nameRFC 2822
Negative integerPre-1970 seconds or milliseconds
  • Sanity check: any numeric value should decode to a believable date in the current era (roughly 2001–2038 for 10-digit seconds)
  • A date near 1970 or thousands of years away means the unit was misread

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)

Resolution and fractional-second precision

Each format above carries a different time resolution. Choosing a format means choosing how finely you can distinguish two moments — from one second down to one nanosecond.

  • 1-second resolution: Unix seconds (10 digits), traditional POSIX time_t
  • 1-millisecond: JavaScript Date, MongoDB BSON Date, Java Instant.toEpochMilli()
  • 1-microsecond: Chrome/WebKit timestamps, Python datetime.timestamp(), PostgreSQL timestamp precision 6
  • 100-nanosecond: Windows FILETIME, .NET DateTime.Ticks
  • 1-nanosecond: Java Instant (full precision), Go time.UnixNano(), JS Temporal.Instant.epochNanoseconds (BigInt)
  • Picosecond and below: PTP/IEEE 1588 wire format (1/2^32 of a second), NTP fraction field
  • Pick the coarsest resolution that meets your needs — sub-second precision is often lost on JSON serialization or string round-trip
  • When converting between formats, route through Unix milliseconds or nanoseconds (via BigInt) — that is the lowest common denominator that preserves precision

Timestamp format converters

Convert between Unix time and the platform-specific timestamp formats you meet in the wild:

FAQ

Is a timestamp the same as Unix time?
In most programming contexts, a timestamp means Unix time: the number of seconds since 1970-01-01 00:00:00 UTC. Some APIs use milliseconds, so check the digit count before converting.
What is a POSIX timestamp?
A POSIX timestamp is Unix time measured as seconds since the epoch, excluding leap seconds. It is the same integer format used by time_t on Unix-like systems.
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 timestamp format does JavaScript use?
JavaScript's Date works in milliseconds — Date.now() returns a 13-digit millisecond timestamp, and new Date(ms) expects milliseconds. Multiply Unix seconds by 1000 before passing them to Date.
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.
What is the RFC 2822 date format?
RFC 2822 (updated by RFC 5322) is the human-readable date format used in email and HTTP headers, such as "Wed, 15 Nov 2023 06:13:20 GMT". JavaScript produces it with date.toUTCString().
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.