ToolSnap

Unix Timestamps Explained: Convert, Compare, and Debug

2026-02-28 4 min read
timestampunixdate-timedeveloper-tools
Written by Osman Coskun

Unix timestamps are the universal language of time in computing. Every server, database, and API understands them. Here’s what they are and how to work with them.

What is a Unix timestamp?

A Unix timestamp is the number of seconds that have elapsed since January 1, 1970, 00:00:00 UTC (known as the Unix epoch).

1710000000 = March 9, 2024, 16:00:00 UTC

That’s it. One number represents one moment in time, anywhere in the world.

Why timestamps exist

Dates are complicated. Time zones, daylight saving time, leap years, different calendar formats β€” all of these make date handling error-prone.

Unix timestamps avoid all of this by:

  • Being timezone-independent β€” The same timestamp means the same instant everywhere
  • Being a simple number β€” Easy to store, compare, and sort
  • Having no ambiguity β€” β€œ03/04/2024” could be March 4 or April 3 depending on locale. A timestamp has one meaning

Common timestamp formats

FormatValueUnit
Unix (seconds)1710000000Seconds since epoch
Unix (milliseconds)1710000000000Milliseconds since epoch
ISO 86012024-03-09T16:00:00ZHuman-readable

JavaScript uses milliseconds: Date.now() returns milliseconds. Most APIs and databases use seconds.

Be careful not to mix them up β€” a millisecond timestamp divided by 1000 gives you seconds.

Practical conversions

Timestamp to human date

new Date(1710000000 * 1000).toISOString()
// "2024-03-09T16:00:00.000Z"

Human date to timestamp

new Date("2024-03-09T16:00:00Z").getTime() / 1000
// 1710000000

Current timestamp

Math.floor(Date.now() / 1000)

The Year 2038 problem

32-bit systems store Unix timestamps as a signed 32-bit integer, which maxes out at:

2,147,483,647 = January 19, 2038, 03:14:07 UTC

After that, the value overflows and wraps to a negative number (interpreted as 1901). This is the β€œY2K38” problem.

Most modern systems use 64-bit timestamps, which won’t overflow for another 292 billion years. But legacy systems, embedded devices, and some databases still use 32-bit timestamps.

Timestamps in databases

DatabaseTypeNotes
PostgreSQLTIMESTAMP WITH TIME ZONEStored as UTC internally
MySQLDATETIME or TIMESTAMPTIMESTAMP auto-converts to UTC
SQLiteINTEGER or TEXTStore as Unix timestamp for simplicity
MongoDBDateStored as milliseconds since epoch

Tips

  • Always store in UTC β€” Convert to local time only for display
  • Use seconds or milliseconds consistently β€” Don’t mix within the same system
  • Be explicit about timezone β€” When displaying dates, always show the timezone
  • Use ISO 8601 for APIs β€” 2024-03-09T16:00:00Z is unambiguous and widely supported

A timestamp converter tool lets you quickly check what a timestamp means, convert dates to timestamps, and see the current time β€” useful when debugging APIs or reading logs.

Try it yourself

Use the tool mentioned in this article β€” free, no sign-up, runs in your browser.

Open Tool