Unix timestamp: seconds vs milliseconds

Unix time counts seconds since 1970-01-01 UTC. Many JavaScript APIs use milliseconds instead. Mixing them shifts dates by about 50 years.

Quick tell

In JavaScript, Date.now() and date.getTime() are milliseconds. exp in a JWT is seconds.

  • 10 digits (~1.7e9 today) → almost certainly seconds.
  • 13 digits (~1.7e12) → almost certainly milliseconds.
  • 16–19 digits → microseconds or nanoseconds (less common in web APIs).

Conversions

# seconds → ms
echo $((1700000000 * 1000))

# ms → seconds
echo $((1700000000000 / 1000))

# JS
new Date(1700000000 * 1000).toISOString();
Math.floor(Date.now() / 1000);

Leap seconds and time zones

Unix time ignores leap seconds. Display in a time zone is separate from the integer itself. The converter shows UTC and your local zone.

Questions

Why is my date in 1970?
You passed seconds to an API that expects milliseconds (or the reverse). Multiply or divide by 1000.
Is epoch always UTC?
The instant is UTC-based. Formatting it in Sydney or New York is a display choice.

See also

Related tool: Unix timestamp converter. Runs in your browser; input is not uploaded.