All articles

Unix Timestamps: Epoch Time, Precision and Time Zones

Understand Unix timestamps in seconds and milliseconds, UTC conversion, time zones, precision and practical application behavior.

Digital clock and timeline flowing from the Unix epoch into modern systems

Introduction

Computers need a compact way to represent an instant without storing a formatted sentence such as July 16 at noon. Unix time provides that coordinate by counting elapsed time from the Unix epoch: 1970-01-01 00:00:00 UTC.

Timestamps are used in databases, JWT claims, logs, cache expiration, analytics, schedulers and APIs. The utily.tools Unix Timestamp converter translates between numeric values and human-readable date components for quick validation.

An instant measured from a shared origin

A Unix timestamp normally counts seconds since the epoch, although JavaScript and many APIs use milliseconds. The number identifies an instant in UTC and does not contain a time-zone label. A local date display is a projection of that instant through time-zone rules.

Calendar arithmetic is more complex than elapsed-time arithmetic. Time zones change offset because of daylight-saving rules and political decisions. Leap seconds are not represented consistently by common Unix-time implementations, which typically treat days as 86,400 seconds.

Technical foundations and behavior

Epoch values are commonly expressed in seconds, milliseconds, microseconds or nanoseconds. Conversion therefore requires an explicit unit and a defined rounding policy. A 13-digit millisecond value interpreted as seconds points thousands of years into the future, while truncating subsecond precision can change ordering or expiration behavior.

Seconds versus milliseconds

A ten-digit contemporary value usually indicates seconds, while a thirteen-digit value usually indicates milliseconds. Guessing by length is convenient for a UI but an API contract should specify the unit explicitly.

UTC and local constructors

new Date(year, month, day) interprets components in the local time zone. Date.UTC builds a millisecond timestamp from UTC components. Mixing these functions can shift the output by the local offset.

Range and precision

The historical 2038 problem affects signed 32-bit seconds. Modern JavaScript Number safely represents contemporary millisecond timestamps, but nanosecond values require BigInt or strings to avoid precision loss.

Real-world applications

JWT expiration

The exp claim uses NumericDate seconds. Comparing it directly with Date.now() milliseconds produces an incorrect result unless units are normalized.

Log correlation

Services in different regions can record one UTC instant and let observability tools render it in the investigator’s local zone.

Cache control

An expiration instant can be compared numerically with the current epoch time without parsing localized date strings.

Standards and deeper technical reference

POSIX time and the Unix Epoch

POSIX defines seconds since the Epoch relative to 1970-01-01 00:00:00 UTC. Its arithmetic intentionally ignores leap seconds, which keeps each civil day at 86,400 counted seconds in the model. A Unix timestamp therefore identifies an instant through a scale used by systems; it is not a formatted date and contains no time-zone identifier.

Negative values represent instants before the Epoch when the implementation supports them. Fractions or separate nanosecond fields represent subsecond precision. JavaScript Date uses milliseconds since the Epoch, while many APIs and databases use seconds, producing the common 1,000-fold conversion error.

Common epoch representations
RepresentationUnitExample concern
POSIX time_tTraditionally secondsSigned width and range are implementation-defined
JavaScript DateMillisecondsIEEE 754 Number and Date range rules apply
JWT NumericDateSeconds, fractions permittedValidate exp, nbf and iat with controlled clock skew
Database timestampVendor-specific seconds or microsecondsMay be with or without time-zone semantics
Unix nanosecondsNanosecondsUsually requires a 64-bit integer or BigInt

Time zones, calendars and ISO 8601

Converting an instant to a local date requires a time-zone rule set such as the IANA Time Zone Database. An offset like -03:00 describes one displacement but not future daylight-saving transitions. Store an instant in UTC and retain a named zone such as America/Sao_Paulo when the original civil-time intent matters.

ISO 8601 and RFC 3339 define textual date-time representations, not Unix timestamps. A trailing Z means UTC; an explicit offset ties the local fields to an instant. A date-time without an offset is ambiguous and must not be silently assumed to be UTC in cross-system APIs.

The Year 2038 problem and safe conversion

A signed 32-bit seconds counter reaches 2,147,483,647 at 2038-01-19 03:14:07 UTC and overflows on the next second. Modern 64-bit systems avoid that near-term boundary, but file formats, embedded devices and database columns can retain 32-bit constraints. Conversion code should validate its accepted range rather than relying on host overflow behavior.

Round trips should be tested at the Epoch, before 1970, around daylight-saving transitions, at leap days, with fractional seconds and at range boundaries. Formatting belongs at the display edge; calculations should operate on instants or duration-aware temporal types.

Primary specifications and references

Conclusion

Unix time is a simple coordinate for an instant, but correct use depends on units, UTC interpretation, precision and display-time zone. Most timestamp bugs come from mixing those layers.

My recommendation is to keep machine values in a documented UTC-based format and localize only at the interface boundary. Verify conversions with the utily.tools Unix Timestamp page and continue with articles about JWT claims and distributed identifiers.

Open Unix Timestamp Read more articles