A Unix timestamp is a single number that names a moment in time: the count of seconds since 00:00:00 UTC on 1 January 1970, a point called the Unix epoch. Computers like it because it is one integer, it has no time zone, and it sorts and subtracts easily.
A few reference values
| Timestamp | Date and time (UTC) | Note |
|---|---|---|
| 0 | 1970-01-01 00:00:00 | The epoch |
| 1000000000 | 2001-09-09 01:46:40 | One billion seconds |
| 1516239022 | 2018-01-18 01:30:22 | The iat value in a popular JWT sample |
| 1700000000 | 2023-11-14 22:13:20 | A round number in the 2020s |
| 2147483647 | 2038-01-19 03:14:07 | Largest signed 32-bit value |
You can check any of these in our Unix timestamp converter.
Seconds or milliseconds?
The classic Unix timestamp counts seconds, but many systems count milliseconds instead. JavaScript's Date.now() returns milliseconds, while most databases and server logs use seconds. The easiest way to tell them apart is to count digits. A current timestamp in seconds has 10 digits (for example 1700000000), and one in milliseconds has 13 (1700000000000).
If you feed a millisecond value to something that expects seconds, you get a date tens of thousands of years in the future. If you do the reverse, you get a date in January 1970. Both are a quick sign that the unit is wrong.
Time zones
A Unix timestamp has no time zone. It always refers to one instant, and the same number is the same moment everywhere. The time zone only matters when you display it: 1700000000 is 22:13:20 in UTC, 17:13:20 in New York and 09:13:20 the next day in Sydney (using the offsets in force on 14 November 2023, when Sydney was on daylight saving time). Store and compare timestamps in UTC, and convert to local time only for people to read.
How to convert a timestamp to a date
- Excel or Google Sheets:
=A1/86400+DATE(1970,1,1), then format the cell as date and time. For milliseconds, divide by 86400000 instead. The result is in UTC. - JavaScript:
new Date(ts * 1000).toISOString()for seconds, ornew Date(ts).toISOString()for milliseconds. - Python:
datetime.fromtimestamp(ts, tz=timezone.utc)withfrom datetime import datetime, timezone. - PostgreSQL:
to_timestamp(ts). - MySQL:
FROM_UNIXTIME(ts), which uses the session time zone. - Linux shell:
date -u -d @1700000000. On macOS usedate -u -r 1700000000.
Going the other way, Python's int(datetime.now(timezone.utc).timestamp()) and JavaScript's Math.floor(Date.now() / 1000) both give the current time in seconds.
Negative timestamps and leap seconds
A negative timestamp is a moment before 1970: -86400 is 31 December 1969. Most modern languages handle these, though some older systems do not.
Unix time also ignores leap seconds. Every day is treated as exactly 86,400 seconds long, so the count does not include the occasional extra second that UTC adds. For most applications this makes no difference, but it means Unix time is not an exact count of elapsed physical seconds.
The year 2038 problem
Some older systems store the timestamp in a signed 32-bit integer, whose largest value is 2147483647. That number is 03:14:07 UTC on 19 January 2038. One second later, the value overflows and wraps to a large negative number, which would read as December 1901. Modern systems use 64-bit integers, which will not overflow for about 292 billion years, so the risk is mostly in embedded devices, old databases and legacy file formats. If you maintain such systems, check where timestamps are stored and what type the column or field uses.
Timestamps in JWTs
The exp, nbf and iat claims in a JSON Web Token are Unix timestamps in seconds. If a login keeps failing, converting exp to a date is a fast way to see whether the token has expired. Our guide on how to read a JWT walks through this.
Quick summary
A Unix timestamp counts seconds from 1 January 1970 UTC. Ten digits means seconds and thirteen means milliseconds, the number itself has no time zone, and 32-bit storage runs out on 19 January 2038.
Try it: Convert any timestamp with the Unix timestamp converter.
Related tools
- Unix Timestamp Converter: Convert epoch timestamps to readable dates and dates back to timestamps, in any common unit.
- JWT Decoder: Decode a JSON Web Token locally to read its header, payload and expiry without sending it anywhere.