Skip to content
Built in Lahore, PakistanHow we check the math
mathbehind

Unix Timestamps Explained, and Why 2038 Matters

A Unix timestamp is a count of seconds since 1 January 1970 UTC. Here is how to read one, the seconds vs milliseconds trap, and what happens in January 2038.

By Muhammad Ahmad, Software EngineerLinkedIn· figures checked

Published , updated . 4 min read.

Want to run your own numbers?Unix Timestamp ConverterOpen the calculator

Open almost any database, log file or API response and you will find numbers like 1735689600 where you expected a date. That is a Unix timestamp: the number of seconds since midnight UTC on 1 January 1970, a moment known as the Unix epoch.

Storing time this way has real advantages. It is a single number, it sorts correctly, it is easy to subtract, and it means the same instant everywhere in the world, regardless of time zones.

Reading a timestamp

  • 0 is Thursday, 1 January 1970, 00:00:00 UTC.
  • 1735689600 is Wednesday, 1 January 2025, 00:00:00 UTC.
  • Negative numbers are moments before 1970, although some older systems do not support them.

A timestamp is always in UTC. Converting it to local time is a separate step, done when you display it, and that is where time zones and daylight saving come in.

Seconds or milliseconds?

Unix time is defined in seconds, but JavaScript's Date.now() and many web APIs use milliseconds. That gives you a quick check: a current timestamp in seconds has 10 digits, and one in milliseconds has 13.

Mixing them up is one of the most common date bugs. Treat a millisecond value as seconds and you get a date tens of thousands of years in the future. Treat seconds as milliseconds and you land in January 1970.

The year 2038 problem

Many older systems stored timestamps as signed 32-bit integers. The largest number a signed 32-bit integer can hold is 2,147,483,647.

The last second a 32-bit timestamp can hold
  1. Largest signed 32-bit value

    2³¹ − 1equals2,147,483,647

  2. As a date

    2,147,483,647 s after the epochequals19 Jan 2038, 03:14:07 UTC

One second later, a 32-bit counter overflows and wraps around to a large negative number, which systems read as a date in December 1901. It is the same kind of problem as Y2K, but for software that stores time as a 32-bit number.

Are you affected?

Most modern operating systems, languages and databases now use 64-bit timestamps, which will not run out for billions of years. The risk sits in older code and hardware: embedded devices, legacy databases, file formats with fixed 32-bit time fields, and any code that squeezes a timestamp into a 32-bit integer.

The exact moment

A signed 32-bit integer can hold values up to 2,147,483,647. Counted in seconds from 1 January 1970, that runs out at 03:14:07 UTC on 19 January 2038. One second later, a 32-bit counter wraps to its most negative value, which reads as 20:45:52 UTC on 13 December 1901. Software that stores time this way would suddenly think it is more than a century in the past.

It is already a problem for dates in the future

You do not have to wait until 2038 to be affected. Any system that stores a future date in a 32-bit timestamp breaks as soon as that date is after 19 January 2038. A 20- or 30-year loan, a long lease, a pension projection or a certificate with a far-off expiry date can hit the limit today. Bugs of this kind have already been reported in systems that calculate dates decades ahead.

Where the fixes stand

  • Most 64-bit systems already use 64-bit time values, which will not run out for billions of years.
  • The Linux kernel added support for 64-bit time on 32-bit platforms in version 5.6, released in 2020, and the GNU C library supports it from version 2.34 when programs are built for it.
  • The biggest remaining risk is in embedded devices, old file formats and databases that will keep running for decades without updates.

Databases to check

In MySQL, the TIMESTAMP column type only covers dates up to 2038-01-19 03:14:07 UTC, while DATETIME goes to the year 9999. If a table stores expiry dates, contract end dates or anything else far in the future, check the column type. In JavaScript, Date uses milliseconds in a 64-bit floating-point number and is safe for hundreds of thousands of years, but values passed to or from other systems may not be.

Leap seconds

Unix time ignores leap seconds: every day is treated as exactly 86,400 seconds. That keeps the arithmetic simple, and it means Unix timestamps are not a precise count of elapsed physical seconds. For almost all business software this does not matter.

Tip: Storing dates after January 2038, like a long contract end date or a mortgage schedule? Test that your stack handles them now, not in 2038.

Questions people ask

Is my 64-bit computer affected by the 2038 problem?
Usually not for the system clock, but data can still be stored in 32-bit fields in files, databases or network protocols. Check anything that saves dates far in the future.
What happens at the 2038 overflow?
A signed 32-bit counter wraps to its most negative value, which reads as 20:45:52 UTC on 13 December 1901.
What is a Unix timestamp?
The number of seconds since 00:00:00 UTC on 1 January 1970. It is always in UTC.
How can I tell if a timestamp is in seconds or milliseconds?
A current timestamp in seconds has 10 digits; in milliseconds it has 13.
What is the year 2038 problem?
Signed 32-bit timestamps run out at 03:14:07 UTC on 19 January 2038 and wrap to December 1901. 64-bit timestamps don't have this problem.
When exactly does the 2038 problem happen?
At 03:14:07 UTC on 19 January 2038, when a signed 32-bit count of seconds since 1970 reaches its maximum of 2,147,483,647.
Is MySQL affected by the year 2038 problem?
The TIMESTAMP column type only covers dates up to 19 January 2038. DATETIME supports dates up to the year 9999.

Sources

  1. Phoronix: Linux 5.6 is the first kernel for 32-bit systems ready to run past 2038
  2. DAVE Developer's Wiki: coping with the Y2038 problem (kernel 5.6, glibc 2.34)