The year 2038 problem
A signed 32-bit integer can count 2,147,483,647 seconds. Counting from 1970, that runs out at 03:14:07 UTC on Tuesday 19 January 2038.
What happens
The largest value a signed 32-bit integer can hold is 231 − 1 = 2,147,483,647. As a Unix timestamp that is 2038-01-19T03:14:07Z. One second later the value needs a 33rd bit. In a 32-bit variable it wraps to the most negative number, −2,147,483,648, which is 1901-12-13T20:45:52Z.
Software that hits this may see time jump back to 1901, compute negative durations, treat everything as expired or nothing as expired, or refuse to start. It is the same kind of bug as Y2K, with a binary limit instead of a two-digit year.
It does not wait for 2038. Anything that handles future dates fails earlier: a 30-year mortgage calculated in 2008, a certificate valid for 20 years, a "never expires" date set far ahead.
What is already fixed
- 64-bit operating systems. Linux, macOS, the BSDs and Windows on 64-bit hardware use a 64-bit
time_t, which lasts about 292 billion years. - 32-bit Linux. The kernel has had 64-bit time system calls for 32-bit architectures since version 5.6 (2020), and glibc 2.34 and later can build programs with a 64-bit
time_twhen_TIME_BITS=64is defined. - Languages that never used 32 bits. JavaScript and Java count milliseconds in 64 bits; Python, Go, Rust and .NET are not affected in their own date types.
Where it remains
- Embedded and legacy 32-bit systems that will still be running in 2038: industrial controllers, routers, vehicles, medical devices. Many cannot be updated.
- Database columns. MySQL's
TIMESTAMPtype ends at2038-01-19 03:14:07UTC. Any column declared as a 32-bitINTholding epoch seconds has the same limit in every database. - File formats and protocols with 32-bit time fields. The ext2 and ext3 file systems, and ext4 with old 128-byte inodes, store 32-bit seconds. Old binary formats, and structures passed between programs, may have the field width fixed for good.
- Your own code. A timestamp stored in an
intin C, Java or C#, a 32-bit field in a binary protocol, or SQL Server'sDATEDIFF(SECOND, …), which returns a 32-bit value and raises an error past the limit.
How to check your systems
- Test the boundary. Feed
2147483647and2147483648through every layer: API, code, database, export. The second should come back as2038-01-19T03:14:08Z, not 1901 and not an error. - Search the schema for
INTcolumns and MySQLTIMESTAMPcolumns that hold times. Move them toBIGINTorDATETIME. - Search the code for timestamps held in 32-bit types:
int,int32_t,Int32, andlongon 32-bit platforms and on 64-bit Windows, wherelongis 32 bits. - On 32-bit Linux, check
sizeof(time_t). If it is 4, rebuild with-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64on a recent glibc.
You can try the two values in the timestamp converter: JavaScript is not affected, so it shows the correct dates on both sides of the limit.
Related limits
| Limit | Value | Reached |
|---|---|---|
| Signed 32-bit seconds | 2147483647 | 2038-01-19T03:14:07Z |
| Unsigned 32-bit seconds | 4294967295 | 2106-02-07T06:28:15Z |
| NTP 32-bit seconds since 1900 | 4294967295 in NTP's own count | 2036-02-07T06:28:15Z |
| Signed 64-bit seconds | about 9.2 × 1018 | in roughly 292 billion years |
An unsigned 32-bit counter buys 68 more years at the cost of every date before 1970.
Questions
What is the exact date and time of the 2038 problem?
03:14:07 UTC on Tuesday 19 January 2038, timestamp 2,147,483,647. The following second cannot be stored in a signed 32-bit integer.
Will 64-bit computers be affected?
The operating systems are not, but 64-bit machines still run software and read databases, files and network protocols that store time in 32-bit fields. Those need fixing one by one.
Is the 2038 problem as serious as Y2K?
The mechanism is similar and the affected systems are harder to reach, because many are embedded devices rather than business software. Mainstream servers, phones and desktops already use 64-bit time.