Convert Unix Timestamp to Date: A Practical Guide
Convert Unix seconds and milliseconds to a readable date, recognize the unit from its length, and avoid time-zone errors.

To convert a Unix timestamp to a date, first determine whether the value is counted in seconds or milliseconds. Both use the same 1970 UTC reference point, but confusing their units moves the result by thousands of years.
The Basic Definition
Unix time counts elapsed seconds since 1970-01-01 00:00:00 UTC. A value such as 1700000000 is a seconds timestamp. It describes an instant in UTC; a local display adds the appropriate time-zone offset.
Recognize the Unit From Its Length
Modern seconds timestamps typically have 10 digits. JavaScript's Date.now() and many web APIs use 13-digit milliseconds. Microseconds and nanoseconds are longer still.
- 10 digits: usually seconds
- 13 digits: usually milliseconds
- 16 digits: often microseconds
- 19 digits: often nanoseconds
This is a useful clue, not an absolute rule for dates very far from today.
Convert Without a Zone Error
Convert the number to UTC first. Then choose the city or time zone for display. If an API says a timestamp is UTC, do not add an offset before converting and then let the display add it again. That double adjustment is a common source of wrong dates.
Seconds and Milliseconds
To pass seconds into a JavaScript date constructor, multiply by 1,000. To turn milliseconds into Unix seconds, divide by 1,000 and decide whether the fractional remainder must be preserved.
Keep the original value, its declared unit, and its time zone in logs or exports. A timestamp is compact, but those three details make it interpretable years later.