Skip to content
Developer GuideDevelopment

Unix Timestamp Explained

Understand Unix timestamps, the Unix epoch, seconds versus milliseconds, UTC and local time zones, negative values, and JavaScript date conversion.

What is a Unix timestamp?

A Unix timestamp represents an instant as elapsed seconds from 1970-01-01 00:00:00 UTC, ignoring leap seconds in the conventional model. It is compact, sortable, and widely used in operating systems, databases, logs, APIs, and token claims.

The number is not a formatted calendar date. Software converts it into a date and applies a display time zone when presenting it to a person.

Seconds versus milliseconds

Unix seconds

1788134400

JavaScript milliseconds

1788134400000

The millisecond form is exactly 1,000 times the second form for the same instant. A value interpreted with the wrong unit can produce a date near 1970 or far outside an application's expected range.

UTC, local time, and time zones

A timestamp identifies one instant globally. Formatting that instant in UTC, Asia/Shanghai, America/New_York, or another zone can produce different calendar dates and clock times.

Daylight-saving rules affect local display and scheduled wall-clock behavior, but they do not change the underlying instant represented by the timestamp.

Negative timestamps

Negative values count backward from the epoch. For example, -1 represents one second before 1970-01-01 00:00:00 UTC. Language, database, and platform date ranges vary, so historical values should be tested in the target environment.

Unix timestamps in JavaScript

const seconds = 1788134400;
const date = new Date(seconds * 1000);

console.log(date.toISOString());
const milliseconds = Date.now();
const unixSeconds = Math.floor(milliseconds / 1000);

Use the Unix Timestamp Converter to compare seconds, milliseconds, UTC, and your browser's local representation.

Unix timestamps in JWTs and schedules

JWT NumericDate claims use Unix seconds; see How to Decode a JWT before interpreting exp, iat, or nbf.

A cron expression is different: it describes recurring calendar fields rather than one absolute instant. Read the Cron Expression Guide for scheduling syntax and time-zone considerations.

FAQ

Frequently asked questions

What is the Unix epoch?

The Unix epoch is 1970-01-01 00:00:00 UTC, the reference instant from which Unix timestamps count elapsed time.

Are Unix timestamps in seconds or milliseconds?

Traditional Unix time uses seconds. JavaScript Date timestamps use milliseconds, while APIs may choose either, so the unit must be confirmed.

Does a Unix timestamp contain a time zone?

No. It identifies an instant relative to UTC. A time zone is applied only when that instant is formatted for display.

Can Unix timestamps be negative?

Yes in systems that support them. A negative value represents an instant before the Unix epoch.

What unit do JWT time claims use?

JWT NumericDate values such as exp, iat, and nbf are expressed in seconds since the Unix epoch, not JavaScript milliseconds.

← Back to Developer Guides