How Unix timestamps work
A Unix timestamp (also called epoch time or POSIX time) is the number of seconds that have passed since 00:00:00 UTC on 1 January 1970, a moment known as the Unix epoch. For example, 1700000000 is 14 November 2023 at 22:13:20 UTC. Computers like this format because it is a single number: easy to store, compare, sort and subtract, with no time zones, month lengths or daylight saving to worry about. It is what you will usually find in database columns, log files, JWT tokens and API responses.
Seconds, milliseconds and more
Unix and most back-end languages count in seconds, while JavaScript (Date.now()), Java and many APIs use milliseconds. Some systems go further, with microseconds or nanoseconds. You can tell them apart by length: a current timestamp has 10 digits in seconds, 13 in milliseconds, 16 in microseconds and 19 in nanoseconds. This converter detects the unit from the size of the number, and you can override it with the unit buttons if it guesses wrong (for example for millisecond timestamps from early 1973).
Time zones
A timestamp always refers to one exact instant, the same everywhere in the world. Time zones only matter when you turn it into a calendar date and clock time. That is why the results show both your local time and UTC. When you convert a date back into a timestamp, choose whether the date you entered is in your local time or in UTC, since the same wall-clock time in two zones is two different instants.
Negative timestamps and the year 2038 problem
Dates before 1970 have negative timestamps: -86400 is 31 December 1969. At the other end, many older systems store the timestamp as a signed 32-bit integer, whose largest value is 2147483647. That moment is 19 January 2038 at 03:14:07 UTC, and one second later such a counter overflows and wraps around to December 1901. Modern systems use 64-bit integers, which push the limit billions of years into the future.
Leap seconds
Unix time pretends every day has exactly 86,400 seconds and ignores leap seconds. That keeps date arithmetic simple, at the cost of Unix time not being a perfect count of elapsed SI seconds.
Getting the current timestamp in code
- JavaScript:
Math.floor(Date.now() / 1000) - Python:
int(time.time()) - PHP:
time() - Go:
time.Now().Unix() - Shell:
date +%s - SQL (PostgreSQL):
EXTRACT(EPOCH FROM NOW())