A Unix timestamp (also called epoch time or POSIX time) is the number of seconds that have passed since 1 January 1970 at 00:00:00 UTC, a moment known as the Unix epoch. For example, 1700000000 is 14 November 2023, 22:13:20 UTC. Because it's a single number in UTC, it's easy to store, sort and compare, and it means the same moment in every time zone, which is why APIs, databases, logs and JWTs use it.
Seconds, milliseconds and more
Not every system counts in seconds. The quickest way to tell is the number of digits for a current date:
| Seconds | 10 digits | 1700000000 | PHP time(), Python int(time.time()), JWT exp |
|---|---|---|---|
| Milliseconds | 13 digits | 1700000000000 | JavaScript Date.now(), Java System.currentTimeMillis() |
| Microseconds | 16 digits | 1700000000000000 | Some logging and analytics systems |
| Nanoseconds | 19 digits | 1700000000000000000 | Go's UnixNano(), tracing systems |
Mixing them up is a classic bug: reading milliseconds as seconds lands you tens of thousands of years in the future, and reading seconds as milliseconds lands you in January 1970.
In JavaScript
Date.now(); // current time in milliseconds
Math.floor(Date.now() / 1000); // current time in seconds
new Date(1700000000 * 1000).toISOString(); // "2023-11-14T22:13:20.000Z"
Math.floor(new Date("2024-01-05T09:30:00Z").getTime() / 1000); // 1704447000In Python
import time
from datetime import datetime, timezone
int(time.time()) # current time in seconds
datetime.fromtimestamp(1700000000, tz=timezone.utc) # 2023-11-14 22:13:20+00:00
int(datetime(2024, 1, 5, 9, 30, tzinfo=timezone.utc).timestamp()) # 1704447000In the terminal
date +%s # current timestamp
date -u -d @1700000000 # Linux (GNU date)
date -u -r 1700000000 # macOS (BSD date)The year 2038 problem
Many older systems stored timestamps as a signed 32-bit integer, whose largest value is 2147483647: 19 January 2038 at 03:14:07 UTC. One second later the number overflows and wraps around to 1901. Modern systems use 64-bit timestamps, which last for billions of years, but embedded devices, old databases and file formats can still be affected. If you store timestamps yourself, use a 64-bit column.
Converting timestamps online
The Epoch Converter turns a timestamp into a date in UTC, your own time zone, ISO 8601 and more, or a date back into a timestamp. It detects seconds, milliseconds, microseconds and nanoseconds by length, and converts a whole list at once if you paste one per line. Decoding a token? The JWT Decoder shows exp and iat as dates automatically.