What a Unix timestamp is
A Unix timestamp counts the time since 1 January 1970 00:00:00 UTC, called the Unix epoch. It has no time zone: the same moment has the same timestamp everywhere. That makes it a good way to store and compare times, and it’s why APIs, databases and JWTs use it.
Seconds or milliseconds?
Most backends and JWT claims use seconds (10 digits today, like 1717171717). JavaScript’s Date.now() and Java’s System.currentTimeMillis() use milliseconds (13 digits). Some systems go further: Go and many logging tools use nanoseconds (19 digits). This tool picks the unit from the number of digits. Override it if your value is from an unusual date range.
A date in January 1970 almost always means milliseconds were read as seconds. A date tens of thousands of years from now means the reverse.
Dates without a time zone
2024-05-31T16:08:37Z and 2024-05-31T21:38:37+05:30 are exact moments. A date written without Z or an offset, like 2024-05-31 16:08, is read in your browser’s time zone, so it gives a different timestamp for someone in another country. When you send times between systems, always include the offset or use UTC.
In code
// JavaScript
Math.floor(Date.now() / 1000); // now, in seconds
new Date(1717171717 * 1000).toISOString(); // "2024-05-31T16:08:37.000Z"
// Java
Instant.now().getEpochSecond();
Instant.ofEpochSecond(1717171717); // 2024-05-31T16:08:37Z
// Python
import time, datetime
int(time.time())
datetime.datetime.fromtimestamp(1717171717, datetime.UTC)
// SQL (PostgreSQL)
SELECT to_timestamp(1717171717);
SELECT extract(epoch FROM now())::bigint;The year 2038 problem
Systems that store seconds in a signed 32-bit integer overflow at 2147483647, which is 19 January 2038 03:14:07 UTC. Use 64-bit integers for timestamps in new schemas and APIs.