Year 2038 Problem: The 32-Bit Time Overflow Explained
The year 2038 problem: signed 32-bit time_t overflows at 03:14:07 UTC on 19 January 2038. See the exact moment, what is affected and how systems are fixed.
Updated
The year 2038 problem is a bug in how many computer systems store time. Unix time counts seconds since 1 January 1970, and a signed 32-bit counter runs out at 2,147,483,647 seconds, which is 03:14:07 UTC on 19 January 2038. One second later the value overflows to a negative number and the system believes it is December 1901.
Why the limit exists
Unix-like systems represent a moment as a single integer: the number of seconds since 00:00:00 UTC on 1 January 1970. In C the type for that integer is time_t. The background is in Unix timestamps explained.
For decades time_t was a signed 32-bit integer on most platforms. A signed 32-bit integer has 31 bits for the magnitude and one for the sign, so its range is:
- Maximum:
2^31 - 1 = 2,147,483,647 - Minimum:
-2^31 = -2,147,483,648
About 2.1 billion seconds is a little over 68 years. Counting forward from 1970 puts the end in early 2038, and counting backward puts the start in late 1901.
The exact moment
| Counter value | Binary (32 bits) | Date and time (UTC) |
|---|---|---|
| 2,147,483,646 | 0111...1110 | Tue 19 Jan 2038, 03:14:06 |
| 2,147,483,647 | 0111...1111 | Tue 19 Jan 2038, 03:14:07 |
| -2,147,483,648 | 1000...0000 | Fri 13 Dec 1901, 20:45:52 |
| -2,147,483,647 | 1000...0001 | Fri 13 Dec 1901, 20:45:53 |
Adding 1 to 0111...1111 carries into the top bit, which is the sign bit in two's complement arithmetic. The result is the most negative number the type can hold. Nothing crashes at the hardware level. The counter simply wraps, and every piece of code that reads it sees a date 136 years in the past.
In hexadecimal the maximum is 7FFFFFFF and the wrapped value is 80000000. The Base Converter will show you 2147483647 in binary as 31 ones.
In local time the moment falls on the evening of 18 January in the Americas: 10:14:07 pm Eastern and 7:14:07 pm Pacific.
What can go wrong
What happens next depends on the software. Typical failures:
- Wrong dates. Logs, file timestamps and displayed times show 1901, or 1970 if the code clamps negative values to zero.
- Broken comparisons. "Has this expired?" and "is this newer?" give the wrong answer when one timestamp is before the wrap and one is after. Certificates, sessions, caches and licences all depend on such checks.
- Timers that never fire or fire forever. Code that waits "until time T" may wait 136 years, or return immediately in a loop.
The problem does not wait for 2038. Any calculation that reaches past the limit fails today. A 30 year loan computed in 2008 already ended after the cutoff. One widely reported early case came in May 2006, when AOLserver software that used a timeout of one billion seconds for "never expire" began failing, because one billion seconds ahead had crossed into 2038.
What is affected
Modern 64-bit desktops, phones and servers are generally safe at the operating system level. The risk is concentrated elsewhere:
- Embedded and industrial devices. 32-bit controllers in vehicles, appliances, network equipment, medical devices and factory systems often run for decades and are hard to update.
- Old 32-bit operating system builds. 32-bit Linux distributions built with a 32-bit
time_t, and software compiled against them. - Databases. MySQL's
TIMESTAMPcolumn type stores a 32-bit epoch value and tops out at2038-01-19 03:14:07UTC. Epoch seconds stored in a plain 32-bitINTcolumn have the same ceiling in any database. - File systems and file formats. Formats with 32-bit timestamp fields, including older ext3 volumes and ext4 volumes created with small inodes, cannot record later times.
- Binary protocols and saved data. Any structure written to disk or sent over a network with a four-byte time field keeps the limit even when both ends run on 64-bit machines.
- Application code. Casting a timestamp to
int, storing it in a 32-bit field, or in JavaScript applying a bitwise operator such as| 0to a seconds value truncates it to 32 bits.
JavaScript itself is not affected: Date stores milliseconds in a 64-bit floating point number.
Related limits
| Storage | Last representable moment (UTC) |
|---|---|
| Signed 32-bit seconds | 19 January 2038, 03:14:07 |
| Unsigned 32-bit seconds | 7 February 2106, 06:28:15 |
| Signed 64-bit seconds | About 292 billion years from now |
An unsigned 32-bit counter doubles the range but cannot represent dates before 1970, so it is a stopgap that some formats use.
How it is being fixed
The fix is simple to state: use 64 bits. A signed 64-bit count of seconds lasts roughly 292 billion years in each direction. The work is in changing every layer without breaking compatibility.
- 64-bit systems. On 64-bit Linux, macOS and the BSDs,
time_thas been 64 bits for many years. - Linux on 32-bit hardware. Kernel 5.6, released in 2020, added 64-bit time support for 32-bit architectures. The GNU C library added an opt-in 64-bit
time_tfor 32-bit builds in version 2.34 (2021) through the_TIME_BITS=64setting, and musl switched to 64-bittime_ton 32-bit targets in version 1.2.0 (2020). - Distributions. Debian moved most of its 32-bit ports to 64-bit
time_tfor the Debian 13 release. - BSD. OpenBSD and NetBSD moved to 64-bit
time_ton all platforms, including 32-bit ones, in the 2010s. - File systems. ext4 with larger inodes stores extra timestamp bits that extend its range by centuries, and XFS gained a "bigtime" feature for the same purpose.
- Databases. Use
BIGINTfor epoch values and date types with a wide range, such asDATETIMEin MySQL ortimestampin PostgreSQL.
Changing the size of time_t changes the layout of every structure that contains one, so libraries and programs must be rebuilt together. That is why the migration takes years, and why devices that will never receive an update are the real concern.
What developers should check
- Search for epoch values stored in 32-bit types:
int,int32_t,longon 32-bit targets, andINTcolumns. - Check binary formats and protocols you own for four-byte time fields.
- Test with future dates. Set a test system's clock past January 2038, or feed timestamps such as
2147483648and4102444800(1 January 2100) through your code. - Check date arithmetic that looks far ahead: expiry dates, schedules, retention periods and financial terms.
- Ask suppliers of embedded devices how their firmware stores time.
The Unix Timestamp Converter is a quick reference while you do this. It converts a timestamp in seconds or milliseconds to its UTC, ISO 8601 and local forms, and converts a date back to an epoch value. To see how long is left, the Duration Calculator gives the time between today and 19 January 2038 in years, months and days.
Try it
Paste 2147483647 into the Unix Timestamp Converter and confirm it reads 19 January 2038, 03:14:07 UTC. Then paste 2147483648. The converter shows 03:14:08 as it should. A system with a 32-bit time_t would show 1901.