Robince Studio
Developer Tools

Unix timestamps explained: seconds, milliseconds and the Year 2038 problem

A Unix timestamp is the number of seconds since 1 January 1970 UTC. Computers love it because it is one number with no time zone and no formatting. This guide explains how to read one, the common seconds-versus-milliseconds trap and the 2038 limit.

3 min read Reviewed Published by Abdul Gani, Robince Studio

On this page
  1. What a Unix timestamp is
  2. Seconds or milliseconds?
  3. Converting to a readable date
  4. Time zones: the same instant, different clocks
  5. Leap seconds and the Year 2038 problem
  6. Frequently asked questions
  7. Try these tools

What a Unix timestamp is

Unix time counts the seconds that have passed since the "epoch": 00:00:00 UTC on 1 January 1970. So 0 means exactly that moment, and 86,400 (the number of seconds in a day) means 2 January 1970.

Some reference points: 1,000,000,000 is 9 September 2001 at 01:46:40 UTC. 1,700,000,000 is 14 November 2023 at 22:13:20 UTC. 1,767,225,600 is exactly midnight UTC at the start of 1 January 2026.

Because it is just a number counted from a fixed UTC moment, a timestamp means the same instant everywhere in the world. Time zones only matter when you display it to a person.

Seconds or milliseconds?

Different systems use different units. Classic Unix, many databases and JWT claims use seconds. JavaScript's Date.now() and many web APIs use milliseconds, which is 1,000 times larger.

You can tell them apart by size. In 2026, a seconds timestamp has 10 digits (about 1.77 billion) and a milliseconds timestamp has 13 digits (about 1.77 trillion). If you convert a 13-digit value as seconds, you get a date tens of thousands of years in the future, which is a quick sign of the mistake.

Rule of thumb: 10 digits means seconds, 13 digits means milliseconds. Some systems also use microseconds (16 digits) and nanoseconds (19 digits).

Converting to a readable date

  • JavaScript: new Date(seconds * 1000).toISOString() gives an ISO 8601 UTC string. Remember to multiply seconds by 1,000.
  • Python: datetime.fromtimestamp(seconds, tz=timezone.utc).
  • Command line on Linux: date -u -d @1700000000. On macOS: date -u -r 1700000000.
  • Spreadsheets: add the number of seconds divided by 86,400 to the date 1 January 1970, then format the cell.

Time zones: the same instant, different clocks

The timestamp 1,700,000,000 is 22:13:20 UTC on 14 November 2023. In India Standard Time (UTC+5:30) the same moment reads 03:43:20 on 15 November 2023. It is the same instant, shown on different clocks, and even the date differs.

Good practice is to store and transmit timestamps in UTC, and convert to the user's time zone only when displaying. Storing local times without the zone is a classic source of bugs around daylight saving changes.

Leap seconds and the Year 2038 problem

Unix time ignores leap seconds: each day is treated as exactly 86,400 seconds, so the count stays simple. That means it is not a perfectly continuous measure of elapsed physical time, which rarely matters for everyday software.

The Year 2038 problem comes from storing the timestamp in a signed 32-bit integer. The largest value is 2,147,483,647, which is 03:14:07 UTC on 19 January 2038. One second later the number overflows and wraps around to a negative value, which many old systems would read as December 1901.

Modern systems use 64-bit timestamps, which will not overflow for about 292 billion years, so the risk is mainly in old embedded systems, legacy databases and file formats that still use 32 bits.

Frequently asked questions

What is the epoch?

The starting point of Unix time: 00:00:00 UTC on 1 January 1970. A timestamp is the number of seconds since then.

Does a Unix timestamp depend on the time zone?

No. It identifies one instant in time everywhere. Time zones only affect how that instant is displayed as a local date and time.

Can a timestamp be negative?

Yes. Negative values represent moments before 1970. For example, −86,400 is 31 December 1969.

How do I get the current timestamp?

In JavaScript, Math.floor(Date.now() / 1000) gives seconds. In Python, int(time.time()). Most databases and command lines also have a function for it.

Try these tools

Keep reading