Timestamp Formats Explained

A timestamp format is the way a moment in time is written down. The main ones are Unix numbers (1735689600), ISO 8601 strings (2025-01-01T00:00:00Z) and RFC 2822 dates for email. Store Unix or ISO 8601 in UTC, and format for people only at display time. To convert any of them, convert it to a date with the main tool.

This comparison is part of learn Unix time. Every example below describes the same instant, the start of 2025 in UTC, so you can compare the timestamp formats directly.

Timestamp Format Comparison Table

Common timestamp formats
FormatExampleUnambiguous instant?Human-readable?Typical use
Unix seconds1735689600Yes (always UTC)NoAPIs, JWT, file systems
Unix milliseconds1735689600000Yes (always UTC)NoJavaScript, Java, analytics
ISO 8601 / RFC 33392025-01-01T00:00:00ZYes, if offset or Z presentYesJSON, logs, config
RFC 2822Wed, 01 Jan 2025 00:00:00 +0000YesPartlyEmail headers
HTTP-dateWed, 01 Jan 2025 00:00:00 GMTYes (always GMT)PartlyHTTP headers
SQL DATETIME2025-01-01 00:00:00NoYesDatabases

“Unambiguous” is the column that matters most. A value that names one instant worldwide can be compared and sorted safely. A value without a zone, like a plain SQL DATETIME, depends on an outside convention that is easy to lose.

The “human-readable” column matters less than it seems. Logs and APIs are read by programs far more often than by people, and any of these formats can be shown to a person after conversion. Pick the storage format for correctness and convenience in code, then format for humans at the last step. Sorting is the other practical concern: Unix numbers sort numerically, and ISO 8601 strings sort correctly as plain text when they all use the same offset, ideally Z.

Unix Timestamp Format (Seconds and Milliseconds)

The Unix timestamp format is a signed integer count of seconds since 00:00:00 UTC on 1 January 1970. It has no separators and no zone, because it is always UTC. Many platforms use milliseconds instead, which adds three digits.

  • Seconds: 10 digits today, e.g. 1735689600. Used by Unix tools, Python, PHP, Go and most SQL functions.
  • Milliseconds: 13 digits today, e.g. 1735689600000. Used by JavaScript and Java.
  • Fractions: some systems send 1735689600.123, seconds with a decimal part.

The strength of the format is arithmetic: subtract two values and you have a duration in seconds. The weakness is that a person cannot read it, and the unit is not written down. See seconds vs milliseconds for how to tell them apart.

ISO 8601 and RFC 3339 Formats

ISO 8601 is the international standard for writing dates and times as text. Its most common form is YYYY-MM-DDTHH:mm:ssZ. RFC 3339 is a stricter profile of it for internet protocols: it always requires the full date, the full time and an offset.

2025-01-01T00:00:00Z           UTC ("Z" = zero offset)
2025-01-01T05:00:00+05:00      same instant, written in UTC+5
2025-01-01T00:00:00.123Z       with milliseconds
2025-W01-3                     ISO week date (Wednesday of week 1)
2025-001                       ISO ordinal date (day 1)

The comparison ISO 8601 vs Unix comes down to readability against compactness. ISO strings are self-describing and sort correctly as text when they share an offset, but they are longer and need parsing. Unix numbers are compact and fast to compare, but opaque. Ordinal dates like 2025-001 are what many people call a Julian date; the Julian date converter reads them in both short and long form. For a deeper look at offsets and the Z suffix, use the ISO 8601 converter.

RFC 2822 and HTTP Date Formats

The RFC 2822 format is the date style of email headers. It names the weekday and month in English and ends with a numeric offset:

Date: Wed, 01 Jan 2025 00:00:00 +0000
Date: Wed, 01 Jan 2025 05:00:00 +0500

HTTP uses a fixed subset of it, called HTTP-date, which is always in GMT. You will see it in Date, Last-Modified, Expires and cookie headers:

Last-Modified: Wed, 01 Jan 2025 00:00:00 GMT

Both are easy to read but awkward to parse and impossible to sort as text, because they start with the weekday. Use them only where a protocol requires them. In JavaScript, new Date(ms).toUTCString() produces the HTTP-date form.

Which Timestamp Format Should You Use?

Here is which timestamp format to use in each situation:

Recommended format by use
SituationRecommended format
Storing in a databaseA UTC-aware column type (timestamptz) or Unix seconds in a 64-bit integer
Public JSON APIsRFC 3339 in UTC, e.g. 2025-01-01T00:00:00Z
Internal services and metricsUnix seconds or milliseconds, with the unit in the field name (created_ms)
Log filesRFC 3339 in UTC with milliseconds
Email and HTTP headersRFC 2822 / HTTP-date, as the protocol requires
Showing to peopleThe reader's locale and zone, formatted at display time

Whatever you choose, never store a local time without its offset, and avoid 32-bit integers for Unix time: they overflow in 2038, as the year 2038 problem explains. For the basics of what a timestamp is, start with what is a timestamp.

Timestamp Format FAQ

What is the best timestamp format for an API?

Use ISO 8601 in UTC with a Z suffix, such as 2025-01-01T00:00:00Z, or the stricter RFC 3339 profile of it. People can read it, it sorts correctly as text, and every language parses it. Unix seconds are a fine alternative for internal services, as long as the documentation states the unit clearly.

Is ISO 8601 the same as RFC 3339?

RFC 3339 is a profile of ISO 8601 for internet protocols. It requires a full date, a full time and an explicit offset or Z, and it allows a space instead of the T separator. ISO 8601 allows many more forms, such as week dates and ordinal dates. Every RFC 3339 timestamp is valid ISO 8601, but not the other way round.

What format is Wed, 01 Jan 2025 00:00:00 GMT?

That is the HTTP-date format, used in headers such as Date, Last-Modified and Expires. It is a fixed subset of the RFC 2822 email date format that always uses GMT. Email headers use the wider RFC 2822 form, which allows any numeric offset, such as Wed, 01 Jan 2025 05:00:00 +0500.