What a Unix timestamp is
A Unix timestamp is the number of seconds that have passed since 1970-01-01 00:00:00 UTC, the "Unix epoch". 1700000000 is 2023-11-14 22:13:20 UTC. Because it is a single number with no time zone, it is easy to store, compare and sort, which is why databases, logs, APIs and tokens use it. The catch is the units and the time zone you show it in. The date converter turns a timestamp into a readable date in any zone and back.
Seconds or milliseconds?
| Digits today | Unit | Used by |
|---|---|---|
10 (1700000000) | seconds | Unix, PostgreSQL extract(epoch …), JWT exp, most APIs |
13 (1700000000000) | milliseconds | JavaScript Date.now(), Java System.currentTimeMillis() |
| 16 | microseconds | Python time.time_ns() // 1000, some databases |
| 19 | nanoseconds | Go UnixNano(), Prometheus samples |
Mixing them is the most common bug: a seconds value read as milliseconds lands in January 1970, and milliseconds read as seconds land tens of thousands of years ahead. Count the digits first. A JWT with exp in milliseconds never expires in practice.
Time zones and ISO 8601
A timestamp has no time zone; only its display does. The same 1700000000 is 22:13 in London (UTC, in November) and 19:13 in São Paulo (UTC−3). When you need text, use ISO 8601 with an offset, 2023-11-14T22:13:20Z or 2023-11-14T19:13:20-03:00, never a local time without offset. Unix time also ignores leap seconds: every day counts exactly 86,400 seconds, which keeps date arithmetic simple.
Getting the current timestamp
Math.floor(Date.now() / 1000); // JavaScript, seconds
new Date(1700000000 * 1000).toISOString(); // '2023-11-14T22:13:20.000Z'import time, datetime
int(time.time())
datetime.datetime.fromtimestamp(1700000000, datetime.timezone.utc)date +%s # now
date -u -d @1700000000 # GNU/Linux
date -u -r 1700000000 # macOSSELECT extract(epoch FROM now()); -- PostgreSQL
SELECT to_timestamp(1700000000); -- PostgreSQL
SELECT UNIX_TIMESTAMP(), FROM_UNIXTIME(1700000000); -- MySQLThe year 2038 problem
Systems that store the timestamp as a signed 32-bit integer overflow at 2147483647, which is 2038-01-19 03:14:07 UTC; one second later they jump back to 1901. Modern 64-bit systems are safe, but old embedded devices, file formats and database columns declared as INT still need checking. To compute durations between dates, use the date calculator; for ids that embed a timestamp, see UUID v4 vs v7.
FAQ
Is a Unix timestamp always UTC?
Yes. It counts seconds since an instant defined in UTC, so it is the same number everywhere; only the conversion to a local date depends on a time zone.
How do I know if a timestamp is in seconds or milliseconds?
Count the digits: around 10 for seconds and 13 for milliseconds for any date between 2001 and 2286.
Can a Unix timestamp be negative?
Yes, for dates before 1970: -86400 is 1969-12-31 00:00:00 UTC. Some systems do not accept negative values, so check before storing birth dates that way.
Does Unix time count leap seconds?
No. Each day is exactly 86,400 seconds, and a leap second repeats or smears a second instead of being counted.