Guide / foundations

What is a Unix timestamp?

A precise explanation of the Unix epoch, UTC, negative timestamps, units and what an epoch number actually identifies.

The short definition

A Unix timestamp is a signed count of elapsed time from 1970-01-01T00:00:00Z. In the classic definition, the unit is seconds. Modern APIs also use milliseconds, microseconds and nanoseconds, so a bare number is incomplete unless its unit is known.

Timestamp 0 is the Unix epoch. Timestamp -1 second is 1969-12-31T23:59:59Z. Negative values are valid where the runtime and storage type support them.

UTC and time zones

The timestamp identifies an instant on the UTC timeline. It carries no city, country, daylight-saving rule or preferred display format. Formatting the same timestamp in Shanghai and New York produces different clock readings while preserving the same instant.

Leap seconds

Unix time generally treats each day as 86,400 seconds and does not encode leap seconds as distinct numbered seconds. For most web and database work this convention is expected; scientific timing systems may use other time scales.

A reproducible example

1700000000 seconds converts to 2023-11-14T22:13:20.000Z. Multiplying by 1,000 gives 1700000000000 milliseconds without changing the instant.

Read a timestamp from an API or log

A field called created_at might contain an ISO string, Unix seconds or Unix milliseconds. The field name alone does not identify its format. Check the API specification, paste the value into the timestamp-to-date converter, and choose the documented unit. Compare UTC with the expected event date before copying the result.

SecondsUTC dateMeaning
-11969-12-31 23:59:59One second before the epoch
01970-01-01 00:00:00Epoch origin
17000000002023-11-14 22:13:20A normal modern timestamp
21474836472038-01-19 03:14:07Largest signed 32-bit second value

One instant, different clock readings

For 1700000000, UTC is November 14 at 22:13:20. Shanghai is November 15 at 06:13:20, and New York is November 14 at 17:13:20. The timestamp stays identical; only the calendar presentation changes. Use the time-zone display tool to verify a regional reading.

Unix time is not an atomic clock or an elapsed-duration stopwatch. Common POSIX-style timestamps do not count leap seconds as extra ordinary seconds. Your device clock may also be corrected while the page is open. For measuring a short operation in JavaScript, use a monotonic timer such as performance.now(), rather than subtracting two device-clock dates.

Keep the unit with the value

Store or document the unit alongside a numeric timestamp. Use seconds versus milliseconds when a value looks implausible. To interpret a calendar time instead, use date to timestamp and specify its source time zone.

Standards and runtime references

Tools / 01—06

More timestamp tools

Each route starts with a specific input and gives a specific answer.