ISO 8601 vs Unix Timestamp: Which Format Should You Use?
Unix timestamps are compact numbers for machines; ISO 8601 strings are readable dates for people. Compare both and pick the right one.
Every system that records when something happened has to pick a way to write that moment down. Two formats dominate the choice: the Unix timestamp, a plain number counting seconds since 1970, and ISO 8601, a readable text string such as 2026-12-06T12:00:00Z. They describe the same instant, yet they behave very differently.
The short version: store and calculate with Unix time, communicate and display with ISO 8601. This article compares the two formats and shows one real instant written both ways.
Two common date formats
A Unix timestamp is a single integer; ISO 8601 is a structured string. Both pin down one moment, but they are built for different readers — one for machines, one for people.
What a Unix timestamp is
A Unix timestamp, also called Unix time or epoch time, is the number of seconds since 1970-01-01T00:00:00Z, the Unix epoch. There is no timezone attached, because the count starts from a single instant defined in UTC. The same number means the same moment everywhere.
That simplicity is the format's main strength. Comparing two moments is comparing two integers: the larger number is the later moment. Finding the gap between two events is subtraction, and sorting by time is sorting numbers.
Two details cause most Unix-time bugs. The first is precision: some systems count seconds and others count milliseconds. A current timestamp has 10 digits in seconds and 13 in milliseconds, so counting the digits is the fastest way to tell which one you are looking at. The second is range: a signed 32-bit integer runs out on 19 January 2038 at 03:14:07 UTC. Modern systems use 64-bit integers, which removes the problem.
What ISO 8601 is
ISO 8601 is an international standard for writing dates and times as text. Its most common form writes the largest unit first: 2026-12-06T12:00:00Z. Read left to right: year, month, day, the letter T, hour, minute, second, and the timezone marker.
The final marker matters most. The letter Z stands for Zulu time, meaning UTC, an offset of zero. An explicit offset such as +05:00 says the local clock is five hours ahead of UTC. A string with no marker at all, such as 2026-12-06T12:00:00, is a local time that does not say which instant it is.
ISO 8601 also defines less common forms, including week dates such as 2026-W49-6, but most parsers and APIs never use those. Its internet profile, RFC 3339, narrows ISO 8601 to the form in this article.
The same instant, two ways
Here is one real instant, noon UTC on 6 December 2026, written both ways:
- ISO 8601 (UTC):
2026-12-06T12:00:00Z - ISO 8601 (Pakistan Standard Time):
2026-12-06T17:00:00+05:00 - Unix timestamp (seconds):
1796558400 - Unix timestamp (milliseconds):
1796558400000
All four values are the same moment. The ISO strings tell a human reader the date, the clock time, and the timezone at a glance. The Unix numbers tell a reader nothing without a converter, but a program can compare and sort them without parsing. Drop the Z and the value no longer says which instant it is.
How the two formats compare
| Property | Unix timestamp | ISO 8601 |
|---|---|---|
| Data type | Integer | String |
| Example | 1796558400 | 2026-12-06T12:00:00Z |
| Human-readable | No — needs a converter | Yes, offset visible |
| Timezone handling | Always UTC, by definition | Explicit: Z or an offset |
| Date math | Simple subtraction | Requires parsing first |
| Storage size | 4–8 bytes as an integer | About 20–25 characters |
| Sortable as stored | Yes, numerically | Yes, with a consistent offset |
| Precision | Seconds or milliseconds | Seconds, milliseconds, or finer |
| Leap seconds | Ignored — every day is 86,400 seconds | Can be written as 23:59:60 |
Readability
ISO 8601 wins clearly when a human has to read the value. A support engineer scanning a log line or a developer debugging an API response can make sense of 2026-12-06T12:00:00Z without running anything. A Unix timestamp in the same place is opaque: 1796558400 could be any date in the 2020s. That is why logs and user interfaces almost always show the ISO form, even when the system stores the Unix form underneath.
Timezone handling
Unix time removes timezone ambiguity by construction. Because the number counts from a fixed UTC instant, there is no offset to forget and no daylight-saving transition to mishandle. The timezone only enters the picture when the number is displayed.
ISO 8601 handles timezones by writing them down. That is more flexible — the string can preserve the original local offset, which matters for records such as "the meeting was at 17:00 in Karachi" — but it only works when the offset is actually present. An ISO string without Z or an offset is the most common timestamp bug in APIs: the sender meant UTC, the receiver assumed local time, and every event is silently off by hours.
Date math and sorting
Unix timestamps make arithmetic trivial. Our example instant plus ninety minutes is 1796558400 + 5400 = 1796563800, and the same instant one day later is 1796558400 + 86400 = 1796644800. No calendar rules are involved, because every Unix day is exactly 86,400 seconds.
ISO 8601 strings sort correctly as plain text, but only when every value uses the same offset. Strings ending in Z sort in chronological order because the largest unit comes first. Mix offsets — some Z, some +05:00 — and the text order no longer matches the time order.
Examples in APIs
Most modern systems use both formats and convert between them at the boundary.
JSON APIs
JSON has no date type, so an API has to choose a representation. The common convention is ISO 8601 in the RFC 3339 profile: a string such as "created_at": "2026-12-06T12:00:00Z". It is readable in a raw response, it carries its timezone, and every language has a parser for it. Some high-throughput APIs use Unix seconds instead, for example "created_at": 1796558400, trading readability for compactness. Either choice works if it is documented.
Converting between the formats in code
Every mainstream language converts between the two formats in a line or two. The examples below start from our demo instant and produce 1796558400, or go the other way. If you do not want to write code, the Unix Timestamp Converter on FBSubNet converts in both directions in the browser.
// JavaScript
Math.floor(Date.parse("2026-12-06T12:00:00Z") / 1000); // 1796558400
new Date(1796558400 * 1000).toISOString(); // "2026-12-06T12:00:00Z"
# Python
from datetime import datetime, timezone
int(datetime.fromisoformat("2026-12-06T12:00:00Z").timestamp()) # 1796558400
datetime.fromtimestamp(1796558400, tz=timezone.utc).isoformat() # "2026-12-06T12:00:00+00:00"
Two details are worth noting. In JavaScript, Date.parse and Date.now() work in milliseconds, so converting to seconds needs the division by 1000 — forgetting it is the classic factor-of-1000 bug. In Python, always pass tz=timezone.utc to fromtimestamp; without it the result is a naive local time.
Storage and display tips
Store one way, display the other
The pattern most production systems settle on is to store Unix timestamps and expose ISO 8601. Storage and internal calculations use the integer: compact, unambiguous, and fast to compare. Anything a human or an external system sees — API responses, logs, emails, admin screens — uses the ISO string, because it is readable and self-describing.
Seconds or milliseconds? Pick one and write it down
Unix time has no built-in marker for its own precision, so the unit is a convention your project has to agree on. Seconds are the classic Unix choice; milliseconds are the JavaScript and Java convention, and many JSON APIs use them. A current timestamp has 10 digits in seconds and 13 in milliseconds — a reliable quick check. Document the unit in your API specification and name the field honestly, for example created_at_ms when it is milliseconds.
Always keep the Z, or keep the offset
For ISO 8601, the rule is simple: never emit or accept a date-time string without a timezone marker. Prefer Z for values stored or exchanged in UTC, and keep the original offset only when the local time itself is meaningful, such as a scheduled meeting. When you parse an incoming ISO string, reject one with no offset rather than guessing.
A worked example: one instant, end to end
Here is the demo instant run through the full journey, as you would check it with a tool. Paste 1796558400 into the Unix Timestamp Converter and it reports the UTC ISO form 2026-12-06T12:00:00Z, the epoch milliseconds 1796558400000, and the local display time — 17:00 in Pakistan Standard Time, matching 2026-12-06T17:00:00+05:00.
Now work forward from that instant in both formats. Add ninety minutes: the Unix value becomes 1796563800 by plain addition, while the ISO value becomes 2026-12-06T13:30:00Z. Move one day forward: 1796644800, or 2026-12-07T12:00:00Z. Converting between them is mechanical, so the choice is never about which one is "correct". It is about which reader — a person or a program — will use the value next. For a related walkthrough, see How to Convert a Unix Timestamp to a Readable Date, and the companion guide on Unix Timestamp: Seconds vs Milliseconds Explained if you keep hitting the factor-of-1000 problem.
Which format should you use?
- Storing timestamps in a database: Unix timestamp as a 64-bit integer. Compact, fast to index, and unambiguous.
- Returning dates from a JSON API: ISO 8601 with
Z, following the RFC 3339 profile. - Doing date math or sorting large datasets: Unix timestamp. Subtraction and numeric sorting need no parsing.
- Writing logs a human will read: ISO 8601. A log line should be understandable without a converter.
- Showing a date in a user interface: ISO 8601, converted to the user's local timezone at render time.
- Compact wire formats or embedded devices: Unix timestamp. The integer is smaller and cheaper to parse.
When in doubt, remember the split from the start of this article: Unix time inside the system, ISO 8601 at the edges. That single rule avoids most timestamp bugs.
Common mistakes to avoid
- Mixing seconds and milliseconds. A seconds value read as milliseconds lands in January 1970; a milliseconds value read as seconds lands tens of thousands of years in the future. Check the digit count — 10 versus 13.
- Dropping the timezone marker. An ISO string without
Zor an offset is ambiguous. Always include the marker, and reject incoming values that lack one. - Storing local time without an offset. Local clock times repeat or skip an hour around daylight-saving changes. Store UTC and convert on display.
- Using 32-bit integers for Unix time. They overflow in January 2038. Use 64-bit integers for any new storage.
- Comparing ISO strings with mixed offsets. Text order only matches time order when every value uses the same offset. Normalise to
Zfirst. - Assuming Unix time handles leap seconds. It does not; every Unix day is exactly 86,400 seconds.
Frequently asked questions
Can I convert between ISO 8601 and a Unix timestamp without losing information?
Yes. One instant has exactly one Unix timestamp and one ISO 8601 UTC form, and converting between them is exact at the same precision. The only information that does not survive the round trip is the original local offset, so if the offset itself matters, keep the original string as well as the number.
What does the Z mean in an ISO 8601 string?
The Z stands for Zulu time, the name for UTC. It means the time is given in UTC with zero offset. 2026-12-06T12:00:00Z and 2026-12-06T17:00:00+05:00 are the same instant written in two timezones.
Conclusion
ISO 8601 and Unix timestamps are two views of the same thing: one built for people, one built for machines. ISO 8601 is readable, carries its timezone with it, and is the right default for APIs, logs, and anything a human will see. Unix time is compact, unambiguous, and made for arithmetic, sorting, and storage. The strongest systems use both — Unix integers inside, ISO strings at the edges.
Try it yourself: take any timestamp you are working with, paste it into the Unix Timestamp Converter, and check both forms. Seeing one instant written as 2026-12-06T12:00:00Z and as 1796558400 side by side makes the trade-off concrete.