All tools / Buying guides / Unix timestamp vs ISO 8601: how to choose

Unix timestamp vs ISO 8601: how to choose

The short answer

Store and compute with Unix timestamps (an integer, no timezone ambiguity); transmit and log with ISO 8601 (human-readable, timezone included). The safest pattern: store a timestamp or a timezone-aware timestamptz in the database, and emit ISO 8601 UTC with a Z suffix from your API.

Key differences

AspectUnix timestampISO 8601
Example17695000002026-01-27T08:26:40Z
NatureSeconds since 1970-01-01 UTCString with an explicit timezone
Timezone infoNone — implicitly UTCExplicit (Z or +08:00)
ReadabilityPoor — humans cannot read a date from itGood — readable at a glance
Storage cost4-8 byte integer20-30 byte string
Compare and computeDirect integer comparison, fastestNeeds parsing; lexicographic order works within one format
Year 2038 problem32-bit integers overflowNot affected

Unix timestamp

A single integer counting seconds since 1970-01-01 00:00:00 UTC (the millisecond version has 13 digits). It carries no timezone because it is inherently UTC, comparison is plain integer comparison so sorting and range queries are extremely fast, and it stores cheaply. The downsides: nobody can read a date out of it, and 32-bit integers overflow in January 2038 — always use 64-bit in new systems.

ISO 8601

A string shaped like 2026-01-27T08:26:40Z. The format is fixed and carries its own timezone (Z for UTC, or an explicit +08:00 offset), it is readable by humans, and within a single format lexicographic order equals chronological order so a string sort is a time sort. It is the de facto standard for JSON APIs, log files and HTTP headers. The costs are size and needing to parse before comparing.

How to choose

Related tools

FAQ

How do I tell seconds from milliseconds

Ten digits means seconds, thirteen means milliseconds. Mixing them makes times differ by a factor of 1000 — one of the most common integration bugs around.

What does the Z mean

Z is UTC zero offset (Zulu time). 2026-01-27T08:26:40Z is that instant in UTC, which is 16:26:40 Beijing time.

Will the 2038 problem actually happen

Yes, but only for legacy systems that store timestamps as 32-bit signed integers. Use a 64-bit integer or a database timestamptz column and it never touches you.