Skip to content
Local Only Dev Tools
4 min read

Understanding Unix Timestamps

What epoch time is, seconds vs milliseconds and how to convert safely.

What a Unix timestamp is

A Unix timestamp counts seconds since 1970-01-01 00:00:00 UTC, ignoring leap seconds. It is a convenient, timezone-independent way to store an instant.

Seconds versus milliseconds

JavaScript and many databases use milliseconds; Unix and many APIs use seconds. A 10-digit value is usually seconds, a 13-digit value is usually milliseconds.

Multiplying seconds by 1000 — or dividing milliseconds by 1000 — is the most common conversion bug.

Displaying a timestamp

Always convert to ISO 8601 or an explicit time zone before showing a timestamp to a user. Never assume the viewer's local zone.

Try it yourself

Convert Unix timestamps in seconds or milliseconds to dates and back, in any time zone. Runs locally in your browser.

Open Unix Timestamp Converter