Skip to main content
Skip to main content
DevelopmentJuly 8, 20264 min read

Unix Timestamp: A Developer's Guide

A mismatch between seconds and milliseconds in timestamp handling can cause data integrity issues scheduling failures and security vulnerabilities in production systems.

Convert timestamps with our Timestamp Tool.

What is a Unix Timestamp?

Unix timestamp counts seconds since 1970.

It is a simple way to store dates.

Used by computers worldwide.

The moment 1970-01-01 00:00:00 UTC is the Unix epoch, and a timestamp is the number of seconds since that instant. A value like 1787000000 maps to one point on the timeline with no timezone needed.

Being a plain integer, it ignores daylight saving, leap seconds, and political timezone changes. That is why systems, file formats, and APIs default to it.

Why Use Timestamps?

  • Simple - Just one number
  • Universal - Works everywhere
  • No zones - UTC by default
  • Sortable - Easy to compare
  • Compact - 4 or 8 bytes instead of a date string
  • Comparable - Range queries over one integer
  • Language-agnostic - The same value in JavaScript, Python, SQL, and the shell
  • Stable - The epoch never moves, so old values stay valid

Common Uses

Database storage. Save dates as numbers.

API responses. Compact and fast.

File names. Sort by date easily.

Caching. Check if data is fresh.

Logging. Prefix log lines with a Unix timestamp so tools can sort events across services without parsing human-readable dates.

Session expiry. Compare issued-at and expires-at values as integers, with no date arithmetic or DST surprises.

Signed URLs and tokens. JWTs carry numeric timestamps (iat, exp, nbf) precisely because they are unambiguous.

Unix time in 2026: what every developer should know

Unix time counts seconds since 1970-01-01 UTC and ignores leap seconds. JavaScript's Date.now() returns milliseconds, so always normalize to one unit before comparing values from different sources.

The 2038 problem still matters for 32-bit systems and embedded or IoT devices: on 2038-01-19 03:14:07 UTC, a signed 32-bit counter overflows. Use 64-bit time values or ISO-8601 strings for anything meant to outlive that date; modern servers and browsers are already 64-bit safe.

The TC39 Temporal proposal is steadily moving toward browsers and will eventually make calendar and time-zone math much safer. Until then, keep timestamps in UTC, format them with Intl.DateTimeFormat, and store Unix time for machine-readable values. You can convert both seconds and milliseconds with our timestamp converter.

Timezone pitfalls show up at the formatting boundary, not in storage. If you render 2026-08-17T09:00:00Z with a naive parser, users in Berlin, New York, and Tokyo see different local values. Convert to local time only at the display layer.

Two epoch checkpoints are worth memorizing: 1970-01-01 00:00:00 UTC is timestamp 0, and 2001-09-09 01:46:40 UTC is 1,000,000,000, a handy sanity check for converter output.

FAQ

Q.Will it run out?

A.The counter holds out until 2038-01-19 03:14:07 UTC on signed 32-bit systems, so it does not run out within most of our lifetimes; 64-bit values stay valid for roughly 292 billion years. If your code still uses a 32-bit time_t, typically on embedded or legacy systems, plan a migration, because past that instant the value wraps to a negative number and dates fall back to 1901.

Q.Is it seconds or milliseconds?

A.Unix time itself is defined in seconds, but APIs rarely agree. JavaScript's Date.now() and Date.parse() work in milliseconds, Python's time.time() returns float seconds, Go exposes Unix() and UnixMilli(), and SQL drivers may store either. Before comparing values, normalize both to the same unit: divide milliseconds by 1000 or multiply seconds by 1000, and round or truncate explicitly.

Q.What is the 2038 problem?

A.On 2038-01-19 03:14:07 UTC a signed 32-bit integer can no longer hold the current Unix time and overflows to a negative value, which most systems read as December 1901. Older kernels, embedded devices, and file formats with 32-bit timestamps will misbehave; 64-bit systems are unaffected. If you control a database schema or API, store timestamps as 64-bit integers or UTC ISO-8601 strings.

Q.Unix timestamp or ISO 8601 — which should I store?

A.Both work, and many codebases mix them on purpose. Unix time is compact (8 bytes), timezone-free, and trivial to compare, but unreadable at a glance. ISO 8601 in UTC, for example 2026-08-17T14:30:00Z, reads well in logs and sorts correctly as a string. Store the instant in UTC in either form, never local time, and convert to a display string at the edge with Intl.DateTimeFormat.

References

  • RFC 3339 – Date and Time on the Internet: Timestamps: https://www.rfc-editor.org/rfc/rfc3339
  • MDN – Date (JavaScript): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
  • Unix time – Wikipedia: https://en.wikipedia.org/wiki/Unix_time

Convert timestamps locally

Convert Unix timestamps to dates and back, in UTC and local time, entirely in your browser.

Conclusion

Timestamp bugs are almost always unit or timezone mistakes. Convert and compare locally with the Timestamp Converter.

Both classes of bugs are cheap to catch when you normalize early. If a comparison or query looks wrong, convert seconds and milliseconds side by side before debugging the logic.