Convert Unix timestamp to date

A Unix timestamp is seconds (or milliseconds) since 1970-01-01T00:00:00Z.

Quick conversion rule
const ms = Math.abs(ts) >= 1e12 ? ts : ts * 1000;
const date = new Date(ms);
  • 1700000000 (seconds) and 1700000000000 (ms) represent the same instant.
  • Always display both UTC and local time when debugging cross-region systems.