What Is a Unix Timestamp?
Epoch time explained: seconds, milliseconds and UTC.
Published by QuickUtilaUpdated 2 min read
A Unix timestamp is a single number that identifies a moment in time: the number of seconds that have elapsed since 00:00:00 UTC on Thursday, January 1, 1970. That starting point is called the Unix epoch.
Why computers use timestamps
- A single number is compact to store and fast to compare.
- It has no time zone, daylight saving time or date format to interpret.
- Subtracting two timestamps gives the exact number of seconds between them.
Databases, APIs, log files and authentication tokens use timestamps for these reasons. Humans, though, need them converted back into dates.
Seconds vs milliseconds
The classic Unix timestamp counts seconds. JavaScript, Java and many web APIs count milliseconds instead, giving numbers 1,000 times larger. A present-day timestamp has 10 digits in seconds and 13 digits in milliseconds.
| Format | Example | Digits |
|---|---|---|
| Seconds | 1700000000 | 10 |
| Milliseconds | 1700000000000 | 13 |
Timestamps and time zones
A timestamp always refers to the same instant everywhere in the world. 1700000000 is 22:13:20 on November 14, 2023 in UTC — which is 17:13:20 in New York and 07:13:20 the next day in Tokyo. Only the way it is displayed changes.
Dates before 1970
Moments before the epoch have negative timestamps. −86400 is exactly one day before the epoch: 00:00:00 UTC on December 31, 1969.
The year 2038 problem
Older systems store timestamps as signed 32-bit integers, which can hold values up to 2,147,483,647. That limit is reached at 03:14:07 UTC on January 19, 2038, after which such systems would overflow. Modern operating systems and languages use 64-bit timestamps, which will not run out for billions of years.