The Year 2038 Problem

The year 2038 problem is an integer overflow. Systems that store Unix time in a signed 32-bit integer can count only to 2,147,483,647 seconds, which is 03:14:07 UTC on 19 January 2038. One second later the value wraps to a negative number and reads as 1901. To see both dates, check your timestamp with the main tool.

Signed 32-bit Unix time overflow A number line from −2,147,483,648 (13 December 1901) through 0 (1 January 1970) to 2,147,483,647 (19 January 2038). An arrow from the right end jumps back to the left end, showing the wrap-around. −2,147,483,648 1901-12-13 20:45:52Z 0 1970-01-01 00:00:00Z 2,147,483,647 2038-01-19 03:14:07Z +1 second wraps to the minimum value
The full range of signed 32-bit Unix time. Counting past the right end jumps to the left end.

This explainer is part of learn Unix time. It covers what breaks, why, which systems are still exposed and how the fix works. The bug also goes by Y2K38 and the 2038 bug.

What Happens at 03:14:07 UTC on 19 January 2038

At 03:14:07 UTC on Tuesday, 19 January 2038, Unix time reaches 2,147,483,647, the largest value a signed 32-bit integer can hold. On the next tick, affected software adds one and gets −2,147,483,648. Read as Unix time, that is 20:45:52 UTC on Friday, 13 December 1901.

What happens next depends on the program. Clocks may jump back 136 years. Timers and expiry checks may decide that everything has already expired, or that nothing ever will. Sorting by time puts new records before old ones. Some programs crash on a negative value they never expected. Unix time 2038 overflows at the same instant everywhere, so the local clock time differs by zone: it is 22:14:07 on 18 January in New York.

Why 32-Bit time_t Overflows

C and POSIX represent Unix time with the type time_t. On many older platforms it was a signed 32-bit integer. One bit holds the sign, leaving 31 bits for the value, so the maximum is 231 − 1 = 2,147,483,647 seconds, about 68 years after 1970.

#include <stdint.h>
#include <stdio.h>

int main(void) {
    int32_t t = INT32_MAX;        /* 2147483647 = 2038-01-19T03:14:07Z */
    t = (int32_t)((uint32_t)t + 1); /* wraps in two's complement */
    printf("%d\n", t);
}
Output
-2147483648

The signed type was chosen so that dates before 1970 could be negative. The cost of that choice is the 2038 limit; an unsigned 32-bit counter would have lasted until 2106 but could not represent anything before 1970. This 32-bit time overflow is the same arithmetic you can reproduce in any language with a fixed-width integer.

Which Systems Are Still at Risk

Desktop and server operating systems on 64-bit hardware already use 64-bit time. The risk is in places that are hard to update:

  • Embedded and IoT devices running 32-bit processors and old system libraries, such as routers, industrial controllers, cars and medical equipment that stay in service for decades.
  • Database columns declared as 32-bit integers, and MySQL's TIMESTAMP type, whose range ends at 2038-01-19 03:14:07 UTC. The MySQL Unix timestamp guide covers the fix.
  • File formats and network protocols with a fixed 32-bit seconds field. Changing them breaks compatibility, so they tend to persist.
  • Compiled 32-bit software that was built against a 32-bit time_t and is never recompiled.

Dates in the future arrive early. A 30-year mortgage, a long-lived certificate or a token that expires in 2040 already needs a value past 2038 today, so some systems meet the bug years before the date itself.

How 64-Bit Time Fixes the 2038 Bug

The fix is to store time in a signed 64-bit integer. That pushes the limit out by about 292 billion years, far beyond any practical concern. Modern platforms have made this switch:

  • 64-bit Linux, macOS and BSD have always used a 64-bit time_t.
  • The Linux kernel added 64-bit time interfaces for 32-bit architectures in version 5.6, and glibc 2.34 lets 32-bit programs opt in by building with _TIME_BITS=64.
  • Microsoft Visual C++ has used a 64-bit time_t by default since Visual Studio 2005.
  • Java, JavaScript, Python, Go and .NET store time in 64-bit or larger values.

For your own code and data, the work is an audit: find every place a timestamp is stored, sent or parsed, and make sure each one is 64 bits wide. Store Unix time in BIGINT columns, use 64-bit fields in binary formats, and test with dates after 2038. When you design a data format, you can compare options in timestamp formats.

Y2K vs Y2K38

Y2K compared with Y2K38
Y2KY2K38
Date1 January 200019 January 2038, 03:14:07 UTC
CauseYears stored as two decimal digitsSeconds stored in a signed 32-bit integer
Symptom2000 read as 19002038 read as 1901
WhereBusiness software, mainframes, text recordsC programs, embedded devices, binary formats
FixFour-digit years64-bit time values

Y2K was a formatting problem in how years were written. Y2K38 is an arithmetic problem in how seconds are counted, which makes it harder to spot by reading data. A 32-bit value looks perfectly normal right up to the second it overflows. The good news is the same: the fix is well understood, and most of the work has already been done. For the basics of the counter itself, read about seconds vs milliseconds timestamps.

Check it yourself: paste 2147483647 and 2147483648 into the epoch converter

Year 2038 Problem FAQ

Will my computer stop working in 2038?

Almost certainly not. Current versions of Windows, macOS, Linux on 64-bit hardware, iOS and Android store time in 64-bit values that will not overflow for billions of years. The risk sits in old or embedded 32-bit systems, file formats and database columns that still keep time in a signed 32-bit integer.

What is the exact time of the 2038 problem?

The last second a signed 32-bit Unix time can hold is 2,147,483,647, which is 03:14:07 UTC on Tuesday, 19 January 2038. One second later the counter overflows to −2,147,483,648, which software reads as 20:45:52 UTC on Friday, 13 December 1901. In local time the moment falls on a different hour.

How can I test my software for the 2038 bug?

Set a test machine's clock past 19 January 2038, or inject dates such as 2038-01-19T03:14:08Z and the Unix value 2147483648 into your code, database and APIs. Watch for negative timestamps, dates in 1901, errors on insert and expiry checks that fail. Test certificate and token expiry dates far in the future too.