Local-first tools. Your files and text stay in your browser.

data guide

Unix timestamps explained: seconds, milliseconds and time zones

Unix time is the number of seconds since 1970-01-01 UTC. Learn seconds versus milliseconds, time zones, the 2038 limit and safe conversion.

Reviewed December 3, 2026 · TinkerFern editorial

Unix time is a single number that represents an instant. It is convenient for databases, logs and APIs because it does not contain a time zone, a month name or a daylight-saving rule. The trade-off is that the number is meaningless until you know its unit and how to render it for a person.

What the number counts

Unix time counts from 1970-01-01T00:00:00Z, the Unix epoch. In the common POSIX interpretation it counts seconds, and it deliberately ignores leap seconds. That means Unix time is not a perfect count of elapsed SI seconds, but it is simple and every major system agrees on the conversion.

Two representations dominate:

Representation Example Typical source
Seconds 1700000000 Unix date +%s, many APIs, JWT exp
Milliseconds 1700000000000 JavaScript Date.now(), Java, some APIs

A quick sanity check: current timestamps in seconds have 10 digits; milliseconds have 13. If a value looks like it belongs in the year 55,000, it is probably milliseconds being read as seconds.

Converting in both directions

Most languages expose the epoch directly:

// JavaScript: milliseconds
const now = Date.now();
const fromSeconds = new Date(1700000000 * 1000);
console.log(fromSeconds.toISOString()); // 2023-11-14T22:13:20.000Z
# Python: seconds as a float
from datetime import datetime, timezone
now = datetime.now(timezone.utc).timestamp()
print(datetime.fromtimestamp(1700000000, tz=timezone.utc))

Store instants as UTC epoch values or as ISO 8601 strings with an explicit offset. Do not store a local wall-clock string without an offset and later guess what it meant.

Time zones are a display concern

The epoch itself has no time zone. 1700000000 is the same instant everywhere. What changes is how you format it. 2023-11-15T05:13:20+07:00 and 2023-11-14T22:13:20Z describe the same moment.

That distinction matters when you convert from a wall-clock value to an epoch. A string such as 2023-11-15 05:13:20 is ambiguous until you supply a zone. During a daylight-saving transition, one local time can occur twice, and another can be skipped entirely. A correct converter needs the IANA zone name, not just a fixed offset, because the offset changes across the year.

The Unix timestamp converter handles both directions and lets you pick an IANA zone for wall-clock input. For calendar arithmetic such as “30 days from today”, use the date calculator instead of adding 30 * 86400; that shortcut breaks across DST changes.

The 2038 problem

Many older systems store Unix time in a signed 32-bit integer. The maximum value, 2147483647, corresponds to 2038-01-19T03:14:07Z. One second later, those systems overflow. Modern 64-bit systems are not affected in practice, but embedded devices, older databases and file formats may still be.

If you maintain a format that writes 32-bit timestamps, plan a migration rather than waiting for the date. Widening the column or field is usually safer than redefining the epoch.

Common mistakes

  • Mixing seconds and milliseconds. Multiply or divide by 1000 at the boundary and keep the unit in the variable name, for example createdAtMs.
  • Assuming the browser’s local zone. new Date(string) treats date-only strings as UTC but date-time strings without an offset as local time. Prefer explicit Z or an offset.
  • Formatting with the server’s zone. A server in UTC and a user in Hanoi should see the same instant rendered differently, not two different instants.
  • Sorting formatted dates. Sort numeric epochs or ISO strings, not locale-formatted text.
  • Ignoring clock skew. Distributed systems should allow a small tolerance when comparing timestamps, and should use a trusted time source.

When to use ISO 8601 instead

Epoch values are compact and unambiguous, which makes them good for storage, sorting and protocol fields. They are poor for humans reading a log or a database row. ISO 8601 strings such as 2023-11-15T05:13:20Z are self-describing and sort correctly when they use the same offset and precision.

A practical rule: store the instant as UTC, expose ISO 8601 in APIs meant for people, and use epoch seconds where a compact numeric field is genuinely useful. If the value travels through JSON, check the receiving schema so nobody silently divides milliseconds by 1000 twice.

Checking a value

To inspect a timestamp, paste it into the Unix timestamp converter and switch between seconds and milliseconds. If the result is implausible, verify the unit before changing any code. The JSON formatter is useful when a timestamp is embedded in a larger payload and you need to isolate the field.

Further reading: the POSIX definition of seconds since the epoch, the IANA time zone database, and the ECMAScript Date specification.

Tools mentioned in this guide

Apply the advice with a tool that runs locally.

Continue with a related explainer from the same topic.

All guides →

← All guides · RSS feed

Privacy and cookie settings

This build loads no advertising scripts and no analytics vendor. If analytics is enabled by the owner, it sends only allowlisted event names and tool IDs, never your text, files or generated output.

Analytics
Disabled in this build
Advertising
Disabled in this build
Local storage
Theme, favorite tool IDs, recent tool IDs