Year 2038 problem
The year 2038 problem (Y2038) is a date limit in computers that store time as a signed 32-bit count of seconds since 1 January 1970. Such a count is kept in 32 binary digits (bits) and can hold both positive and negative numbers. It reaches its largest possible value at 03:14:07 UTC on Tuesday, 19 January 2038.[1]
One second later the count overflows, meaning it goes past the largest value it can hold. Affected software may then read the date as 13 December 1901, show some other wrong date, or stop working.[2]
The usual fix is to store the count in 64 bits, which 64-bit systems already do.[3] The risk that remains is in 32-bit devices, old file and database formats, and programs that have not been rebuilt.
Some software has already failed because it calculated dates past 2038.[4]
How computers count time
Unix time and the epoch
Many computers keep the current time as one number, the count of seconds since a fixed starting moment called the epoch. This scheme is called Unix time. The POSIX standard defines the epoch as 00:00:00 UTC on 1 January 1970.[5]
POSIX and time_t
POSIX counts every day as exactly 86,400 seconds, and it gives a formula to turn a calendar date and time into the count.[6]
In the C programming language and on Unix-like systems, this count usually lives in a data type (a kind of value a program uses to store data) called time_t. On 32-bit systems, time_t has long been a signed 32-bit integer.[7]
Why the count runs out
A 32-bit integer has 32 bits, so it can hold only different values. A signed integer uses half of them for negative numbers, so it holds values from to . The largest count of seconds it can hold is
Here is the last second that fits. That is about 68 years, so counting forward from 1970 runs out in January 2038.[1]
| Count of seconds | Date and time (UTC) | Meaning |
|---|---|---|
| −2,147,483,648 | 20:45:52, 13 December 1901 | Smallest value[2][8] |
| 0 | 00:00:00, 1 January 1970 | The epoch[5] |
| 2,147,483,647 | 03:14:07, 19 January 2038 | Largest value[1] |
The rollover
The overflow happens because of how computers store signed numbers. Most use two's complement, where the leftmost bit marks the sign. The largest value is a 0 followed by 31 ones. Adding 1 gives a 1 followed by 31 zeros, which reads as the smallest negative value.[9]
So one second after 03:14:07 UTC on 19 January 2038, a wrapped counter reads −2,147,483,648. Many systems turn that value into 20:45:52 UTC on 13 December 1901.[2] This is an integer overflow, a common kind of software bug.
What happens at the rollover
The result of the overflow is not fixed. It depends on the language, the compiler (the software that turns program code into instructions a computer can run), and how each program uses the time.
- In C, overflow of a signed integer is undefined behavior. The value may wrap around, the program may stop with an error, or the compiler may remove the calculation.[9]
- POSIX does not define what a negative count means. Its date formula applies only to years from 1970 on and to values that are not negative.[6]
- Programs that use 32-bit and 64-bit time side by side can disagree about the date and fail in other ways.[2]
A test by chip maker STMicroelectronics shows that the result varies. On a Linux board set to 03:14:07 UTC on 19 January 2038, a test program built with 32-bit time_t printed 1 January 1970 a second later and stayed stuck there.[2]
On the full system, a logging service failed and the date froze at 1970 instead of 1901. A watchdog timer, which resets the system when software stops responding, fired. The vendor traced this to some programs using 64-bit time while others still used 32-bit time.[2]
Failures before 2038
Software does not have to wait until 2038 to hit the limit. Any program that adds a long span to the current time can produce a date past 2038 today.
An early known case hit the AOLserver web server in May 2006. Some sites had set two database timeouts to 1,000,000,000 seconds, according to reports to work around a bug in the Oracle database driver. After 12 May 2006, the current time plus one billion seconds no longer fit in a signed 32-bit integer and wrapped to a negative value.[4]
The failure started at a count of 1,147,483,648 seconds.[10] Adding one billion seconds to that count gives 2,147,483,648, which is and one more than the largest value a signed 32-bit integer can hold. The result depended on the operating system.[4]
| System | Result |
|---|---|
| Solaris | Server crashed in a threading call[4] |
| Linux | Scheduled tasks stopped running[4] |
List members advised setting the timeouts to zero instead.[4]
What is affected
The problem reaches beyond the system clock. Any place that stores or passes time as a signed 32-bit count of seconds is at risk.
- 32-bit operating systems and programs. On Linux, 32-bit systems used a signed 32-bit count in their system calls.[7]
- Embedded systems and other long-lived devices. Systems put into service now may still be running in 2038.[11] Debian expects the 32-bit ARM platform armhf to be the 32-bit platform most likely to still be used in many new systems over the next decade.[3]
- File systems. The ext4 format stores 32-bit timestamps, with some on-disk variants widening them to 34 bits. Ext3, XFS, and Network File System version 3 (NFSv3, a protocol for sharing files over a network) had similar limits, and these limits affect 64-bit systems too.[7]
- Databases. The
TIMESTAMPtype in MySQL 8.0 covers only 1970-01-01 00:00:01 to 2038-01-19 03:14:07.499999 UTC.[12] - Kernel interfaces. The kernel is the core of an operating system, and its interfaces are the ways programs talk to it. Some device-control calls and some options for timestamps on network connections (sockets) passed 32-bit times and needed new versions.[7][11]
- Login records. The
utmp.handutmpx.hheaders do not work with 64-bit timestamps on platforms wheretime_twas 32 bits.[13]
Fixes
The main fix is a wider counter, but changing the width breaks old programs. Each fix below trades range, compatibility, and effort.
A 64-bit count
Storing the count in 64 bits removes the problem for any practical future. A signed 64-bit seconds field spans about 584 billion years.[14] Most current platforms already use a time_t wide enough for dates after 2038.[13]
Standards and vendors now expect this width.
- POSIX.1-2024 requires
time_tto be an integer type at least 64 bits wide.[15] - In the Microsoft C runtime,
time_tis a 64-bit signed integer by default and supports dates through 23:59:59 UTC on 31 December 3000.[16] - OpenBSD 5.5 (2014) made
time_t64 bits on all platforms after checking its whole source tree.[1]
An unsigned 32-bit count
An unsigned number type cannot store negative values. An unsigned 32-bit count therefore uses all its values for times after 1970, so it lasts until 2106. It cannot represent times before 1970, which file timestamps need, and Linux developers ruled it out for that reason.[7]
OpenBSD used unsigned 32-bit times only in parts of its system that could not use 64 bits.[1]
Wider file system timestamps
File systems store timestamps on disk, so their formats must change too.
- ext4 can widen its timestamps to 34 bits when its inodes (per-file records) are larger than 128 bytes, the default being 256 bytes. These timestamps should not overflow until May 2446.[8]
- XFS gained a "bigtime" option in Linux 5.10 that covers December 1901 to July 2486. It was not on by default at first, to keep compatibility.[17]
Rebuilding software
Changing the size of time_t changes the application binary interface (ABI), the binary rules programs use to call each other. Old compiled programs expect 32-bit time, so systems keep the old interface and add a new 64-bit one beside it.[11]
On Linux the work happened in layers.
- The Linux kernel moved its internal timekeeping to 64 bits, even on 32-bit systems.[11]
- The kernel added 64-bit versions of its time system calls for 32-bit systems, kept apart from the old 32-bit versions.[11]
- Glibc 2.34 (2021) added 64-bit
time_ton 32-bit platforms. Programs choose to use it by setting_TIME_BITSto 64, which also needs_FILE_OFFSET_BITS=64and Linux 5.1 or later.[18] - Distributions rebuild their packages with the new setting.[3]
Debian's switch shows the scale. It renamed more than 1,200 library packages to mark the ABI change. Steve Langasek, who announced the change, judged it the largest cross-archive ABI transition in Debian's history.[19]
Debian switched armel, armhf, and other 32-bit platforms to 64-bit time. It kept i386 on 32-bit time so it can still run old x86 programs, and it left hurd-i386 unchanged because that port's kernel lacks support.[3]
| System | Year | 2038 change |
|---|---|---|
| NetBSD 6.0 | 2012 | Supports post-2038 timestamps on 32-bit x86 and SPARC[13] |
| OpenBSD 5.5 | 2014 | 64-bit time_t on all platforms[1] |
| Linux 5.6 | 2020 | First mainline kernel ready for 32-bit systems past 2038[20] |
| Linux 5.10 | 2020 | XFS bigtime option, timestamps to 2486[17] |
| Glibc 2.34 | 2021 | Optional 64-bit time_t on 32-bit platforms[18] |
| Debian (trixie cycle) | 2024 | 64-bit time_t on 32-bit platforms except i386 and hurd-i386[3][19] |
| POSIX.1-2024 | 2024 | time_t must be at least 64 bits[15] |
History
The 1970 epoch replaced an earlier, shorter count. The first edition of the Unix Programmer's Manual, dated 3 November 1971, measured time in 1/60-second units since 1 January 1971, as a 32-bit number.[21] Its own bug notes said this count lasted only about 2.5 years.[21]
Dennis Ritchie later recalled that the clock was patched more than once by declaring a new epoch. In 1973 the units became whole seconds counted from the start of 1970, which became the standard Unix epoch. As he put it, this "only pushed the issue off to 2038".[21]
Related time limits
Other time formats run out at other dates for the same reason, a fixed number of bits. Ritchie wrote that the early Unix team had "anticipated the millenium bug", the year 2000 problem.[21]
- The Network Time Protocol (NTP) stores an unsigned 32-bit count of seconds since 1 January 1900 in its packets. This field covers 136 years. NTP calls each such cycle an era, and era 0 wraps around in 2036, when era 1 starts.[14]
- An unsigned 32-bit Unix count lasts until 7 February 2106.[1][8]
- ext4's widened timestamps last until May 2446, and XFS bigtime until July 2486.[8][17]
References
- OpenBSD 5.5, OpenBSD Project, 2014.
- How to prevent the year 2038 bug, STMicroelectronics wiki, 2025.
- ReleaseGoals/64bit-time, Debian Wiki, 2024.
- Re: aolserver 3.x not running scheduled procs anymore, AOLserver mailing list, 2006.
- Definitions: 3.125 Epoch, The Open Group Base Specifications Issue 8 (IEEE Std 1003.1-2024), 2024.
- General Concepts: 4.19 Seconds Since the Epoch, The Open Group Base Specifications Issue 8 (IEEE Std 1003.1-2024), 2024.
- System call conversion for year 2038, LWN.net, 2015.
- Index Nodes: Inode Timestamps, The Linux Kernel documentation.
- Arithmetic operators, cppreference.com.
- Re: Something wrong after 2006-05-12 21:25, AOLserver mailing list, 2006.
- Approaching the kernel year-2038 end game, LWN.net, 2019.
- The DATE, DATETIME, and TIMESTAMP Types, MySQL 8.0 Reference Manual, Oracle.
- Avoiding the year 2038 problem, GNU Gnulib manual, GNU Project.
- RFC 5905: Network Time Protocol Version 4, IETF, 2010.
- sys/types.h, The Open Group Base Specifications Issue 8 (IEEE Std 1003.1-2024), 2024.
- time, _time32, _time64, Microsoft Learn.
- XFS File-System With Linux 5.10 Punts Year 2038 Problem To The Year 2486, Phoronix, 2020.
- The GNU C Library version 2.34 is now available, libc-alpha mailing list, 2021.
- 64-bit time_t transition in progress, debian-devel-announce, 2024.
- Linux 5.6 Is The First Kernel For 32-Bit Systems Ready To Run Past Year 2038, Linux.com, 2020.
- Unix Manual, first edition, Dennis M. Ritchie, Bell Labs.
