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
| Format | Value | Unit |
|---|---|---|
| Unix (seconds) | 1710000000 | Seconds since epoch |
| Unix (milliseconds) | 1710000000000 | Milliseconds since epoch |
| ISO 8601 | 2024-03-09T16:00:00Z | Human-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
| Database | Type | Notes |
|---|---|---|
| PostgreSQL | TIMESTAMP WITH TIME ZONE | Stored as UTC internally |
| MySQL | DATETIME or TIMESTAMP | TIMESTAMP auto-converts to UTC |
| SQLite | INTEGER or TEXT | Store as Unix timestamp for simplicity |
| MongoDB | Date | Stored 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:00Zis 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.