TimeStopwatch
Back to blog
Developer2025-06-017 min readThe TimeStopwatch Team

A Developer's Guide to Unix Timestamps

Seconds vs milliseconds, timezone gotchas, and how to safely convert epoch time in your code.

Unix time (also called epoch time or POSIX time) is the number of seconds that have elapsed since January 1, 1970 UTC. It's the closest thing computer science has to a universal, unambiguous clock โ€” which is why it powers everything from your database timestamps to JWT expiry claims.

Seconds or milliseconds?

Here lies the eternal footgun. Most Unix-y systems (Postgres, Python time.time(), curl, JWT exp) use seconds since epoch, while JavaScript's Date.now() uses milliseconds. A 10-digit number is almost certainly seconds; a 13-digit number is almost certainly milliseconds. Our converter auto-detects this.

Timezones don't exist in Unix time

The entire point of Unix time is to be timezone-neutral. It represents a single instant on the global timeline. Timezones only enter the picture when you format that instant for human display. 1717171717 is the same moment whether you're in Tokyo or Toronto โ€” only the wall-clock display differs.

The year 2038 problem

32-bit signed integers overflow at 03:14:07 UTC on 19 January 2038. Modern systems have almost all migrated to 64-bit which pushes the ceiling to roughly 292 billion years in the future โ€” further than the estimated lifetime of stars.

Practical conversion tips

  • To convert a Unix timestamp in JavaScript: new Date(1717171717 * 1000) (multiply by 1000 for seconds โ†’ milliseconds).
  • In SQL: to_timestamp(1717171717) in Postgres, or FROM_UNIXTIME(1717171717) in MySQL.
  • Store timestamps in your database as timestamptz or bigint, never as strings.
  • When displaying to users, always convert to their local timezone at the last possible moment.

Bookmark the Unix Timestamp Converter โ€” you'll use it more often than you'd think.

unixepochdevelopertimezones