Xerobit
Dev Productivity

The Year 2038 Problem: What Breaks on January 19, 2038

The year 2038 problem explained with exact boundary values, C, Python, JavaScript and SQLite overflow runs, and a checklist to see whether your own systems store 32-bit time.

MA Mian Ali Khalid 8 min read
Free tool
Timestamp Converter
Convert Unix timestamps, epoch seconds/milliseconds, and ISO 8601 dates.
Open tool →
On this page ⌄
  1. The boundary values
  2. Overflow reproduced in code
  3. How to check your own system
  4. What is already fixed
  5. Common questions
  6. Limits of this guide
  7. Tested
  8. Sources

The year 2038 problem is an integer overflow. Software that stores Unix time (seconds since 1970-01-01 00:00:00 UTC) in a signed 32-bit integer can hold values only up to 2,147,483,647, which is 03:14:07 UTC on 19 January 2038. One second later the value wraps to -2,147,483,648, which such software reads as 20:45:52 UTC on 13 December 1901. Systems that already use a 64-bit time_t (most 64-bit Linux, macOS and Windows software) are not affected by this specific limit, but any program, file format or database column that still keeps seconds in 32 bits is.

To convert any of the numbers on this page yourself, use the Timestamp Converter. The rest of this guide shows the exact boundary values, code that was run to reproduce the wrap, how to check what your own machine does, and what is already fixed.

The boundary values

A signed 32-bit integer spans -2^31 to 2^31 - 1. Interpreted as seconds from the Unix epoch, those limits (and the unsigned limit) map to these moments. Each date was computed with Python datetime and cross-checked with GNU date, Node.js and PowerShell, which all agreed.

ValueMeaningUTC date and time
21474836472^31 - 1, largest signed 32-bit value2038-01-19T03:14:07Z
2147483648one second later (does not fit in signed 32 bits)2038-01-19T03:14:08Z
-2147483648what the signed 32-bit register holds after the wrap1901-12-13T20:45:52Z
42949672952^32 - 1, largest unsigned 32-bit value2106-02-07T06:28:15Z

So an unsigned 32-bit counter lasts until 2106, but it cannot represent dates before 1970, which is why simply switching time_t to unsigned is not a general fix. Wikipedia's Year 2038 problem article makes the same point and notes that signed 64-bit time takes about 292 billion years to overflow.

Overflow reproduced in code

C: int32_t and time_t

This program adds one second to the largest signed 32-bit value, then prints the date for the result and for the unsigned maximum. It was compiled three ways on Ubuntu 24.04 (glibc 2.39, GCC 13.3.0): native 64-bit, 32-bit (-m32), and 32-bit with a 64-bit time_t.

#include <stdio.h>
#include <stdint.h>
#include <time.h>
int main(void){
  printf("sizeof(time_t)=%zu bits=%zu\n", sizeof(time_t), sizeof(time_t)*8);
  int32_t t = 2147483647;
  uint32_t u = (uint32_t)t + 1u;
  t = (int32_t)u;                       /* wrap */
  printf("t+1    = %d\n", t);
  time_t a = (time_t)t;
  struct tm *g = gmtime(&a);
  char b[64]; strftime(b,sizeof b,"%Y-%m-%dT%H:%M:%SZ",g);
  printf("as date = %s\n", b);
  uint32_t m = 4294967295u; time_t c=(time_t)m; g=gmtime(&c);
  strftime(b,sizeof b,"%Y-%m-%dT%H:%M:%SZ",g);
  printf("uint32 max = %u -> %s\n", m, b);
  return 0;}
Build commandsizeof(time_t)t+1uint32 max as a date
gcc -m64 t.c8-2147483648 (1901-12-13T20:45:52Z)2106-02-07T06:28:15Z
gcc -m32 t.c4-2147483648 (1901-12-13T20:45:52Z)1969-12-31T23:59:59Z
gcc -m32 -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 t.c8-2147483648 (1901-12-13T20:45:52Z)2106-02-07T06:28:15Z

Two things stand out. The int32_t variable wraps in every build, because the wrap is a property of the variable, not of time_t. And in the plain 32-bit build, a 32-bit time_t reads the unsigned maximum as -1, which is 1969-12-31T23:59:59Z. A 64-bit time_t only protects values that actually travel through time_t; a value copied into an int or a 32-bit struct field is still exposed.

(Strictly, signed overflow in C is undefined behaviour; the example converts through uint32_t so the wrap is well defined for the demonstration.)

Python: ctypes.c_int32

Python integers never overflow, so the wrap only appears when a value is forced into a C integer type.

import ctypes
x = ctypes.c_int32(2**31 - 1)
x.value += 1
print(x.value)          # -2147483648  (1901-12-13T20:45:52Z)
print(ctypes.c_uint32(2**32).value)   # 0

Output from Python 3.11: -2147483648 and 0.

JavaScript: safe by default, wraps with | 0 and typed arrays

A JavaScript Number is a 64-bit float, so new Date((2**31) * 1000) gives 2038-01-19T03:14:08.000Z without trouble. The wrap appears only when code forces 32-bit integer semantics:

const max = 2**31 - 1;
console.log((max + 1) | 0);                 // -2147483648
const i = new Int32Array(1); i[0] = max + 1; console.log(i[0]);  // -2147483648
const dv = new DataView(new ArrayBuffer(4));
dv.setInt32(0, max + 1); console.log(dv.getInt32(0), dv.getUint32(0)); // -2147483648 2147483648

Output from Node.js 25.8: all three print -2147483648 (the DataView also reads back 2147483648 as unsigned), and new Date(-2147483648 * 1000).toISOString() is 1901-12-13T20:45:52.000Z. This matters when you write timestamps into a binary file or network packet with setInt32.

SQLite

SQLite stores integers up to 64 bits, so its date functions carry on past the boundary. With SQLite 3.50.4 (the version bundled with Python 3.11 here):

QueryResult
datetime(2147483647, 'unixepoch')2038-01-19 03:14:07
datetime(2147483648, 'unixepoch')2038-01-19 03:14:08
datetime(4294967296, 'unixepoch')2106-02-07 06:28:16
datetime(-2147483648, 'unixepoch')1901-12-13 20:45:52

MySQL: a documented limit (not run here)

The MySQL 8.4 manual, The DATE, DATETIME, and TIMESTAMP Types, states that TIMESTAMP "has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC", while DATETIME supports '1000-01-01 00:00:00' to '9999-12-31 23:59:59'. That is exactly the signed 32-bit window above, so a TIMESTAMP column cannot store a later date. MySQL was not installed for this guide, so the limit is quoted from the manual rather than demonstrated. If you have TIMESTAMP columns that hold future dates (expiry, subscription end, certificate validity), check them against that range.

How to check your own system

QuestionCommand or checkWhat it tells you
Is my OS 64-bit?uname -m (x86_64 and aarch64 are 64-bit) or getconf LONG_BITRun on Ubuntu 24.04 (WSL): x86_64 and 64
How wide is time_t in my build?printf("%zu", sizeof(time_t)) in C8 on 64-bit Linux, 4 for a plain -m32 build (both run above)
Can a 32-bit build use 64-bit time?Build with -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64glibc requires both macros together: its manual says _TIME_BITS=64 "can be defined only when _FILE_OFFSET_BITS=64 is also defined"
Does the program handle the date?date -u -d @2147483648 on the targetA 64-bit userland prints 2038-01-19 03:14:08 UTC
Is a database column 32-bit?Read the type's documented range (MySQL TIMESTAMP ends at 2038-01-19 03:14:07 UTC)Prefer a 64-bit or date-time type for future dates
Does a file or protocol store 32-bit seconds?Read the format specification; look for int32, uint32, long on 32-bit targets in your own structsFormat limits are independent of the OS

The glibc manual's Feature Test Macros page documents _TIME_BITS: defining it as 64 makes time_t a 64-bit integer, and it "can be defined only when _FILE_OFFSET_BITS=64 is also defined". The manual page gives no glibc version number; the gnulib manual's year2038 chapter says that on legacy 32-bit Linux kernels running glibc 2.34 (2021) and later, _TIME_BITS=64 gives wider timestamps. The third build above, which printed sizeof(time_t)=8 under -m32, ran on glibc 2.39.

In source code, search for the usual carriers of 32-bit time: int or long variables that receive time(), uint32_t timestamp fields in structs and wire formats, database columns of 32-bit width, and | 0 or Int32Array in JavaScript that handles epoch seconds.

What is already fixed

  • POSIX. The Open Group's <sys/types.h> specification (Issue 8) says time_t "shall be an integer type with a width of at least 64 bits".
  • Linux kernel. Arnd Bergmann announced that Linux 5.6 "should be the first release that can serve as a base for a 32-bit system designed to run beyond year 2038". The same report lists conditions: user space must be built with a 64-bit time_t, programs calling system calls directly need the time64 syscalls added in Linux 5.1, and some interfaces cannot be changed compatibly (The Register, 2020-01-30). Wikipedia also states that from version 5.6 (2020) 64-bit time_t is supported on 32-bit architectures.
  • File systems. ext2, ext3 and ReiserFS use 32-bit inode times. ext4 with inodes larger than 128 bytes has extra bits that extend the range to 2446, and XFS since Linux 5.10 has an optional "big timestamps" feature extending its range to 2486 (Wikipedia, Year 2038 problem). Bergmann also named ext2, xfs and ufs as file systems with signed 32-bit seconds (The Register). Whether your volume uses the extended format depends on how it was created.
  • 64-bit userland. Most 64-bit operating systems already use a signed 64-bit time_t, so ordinary C programs on them are unaffected by the 32-bit limit, but code that stores times in 32-bit fields still fails (Wikipedia).

What is not the same problem

The NTP timestamp rollover in 2036 is a similar-looking but separate issue: Wikipedia states that "a rollover in Network Time Protocol version 3 and earlier in 2036 is very similar to the 2038 problem, but is not identical". Do not treat the 2036 and 2038 dates as one deadline.

Documented incidents

Wikipedia lists real earlier failures caused by 32-bit time arithmetic. In 2006, AOLserver crashed for requests after 01:27:28 UTC on 13 May 2006 because a timeout one billion seconds in the future overflowed. In 2022, Microsoft Exchange anti-malware updates broke on 1 January 2022 because update version numbers were mapped to Unix timestamps, and Oracle Access Manager threw exceptions from about 17 March 2022 when an expiry roughly 500,000,000 seconds ahead passed the 2038 limit. They show the failure arrives early whenever software adds a long interval to the current time, not only on the 2038 date.

Common questions

What will happen to computers in 2038? Systems that still use a signed 32-bit seconds counter will read the time as December 1901 after 03:14:07 UTC on 19 January 2038. Typical effects are wrong dates, failed certificate or expiry checks and crashes. Systems with 64-bit time are not affected by this limit.

What is 32-bit time? It is a count of seconds since 1970-01-01 UTC stored in 32 bits. Signed, it covers 1901-12-13 to 2038-01-19; unsigned, 1970-01-01 to 2106-02-07.

What is happening on January 19th, 2038? At 03:14:07 UTC the signed 32-bit Unix time reaches its maximum, 2147483647. The next second does not fit.

Will Y2038 be a big deal? For 64-bit systems with current software, no on its own. The risk sits in embedded and 32-bit devices, old binaries, databases with 32-bit time columns and binary file formats. This guide does not estimate how many such systems exist.

Is Y2038 already fixed? Partly. 64-bit time_t is the norm on 64-bit platforms, Linux supports 64-bit time on 32-bit systems from version 5.6, and glibc offers it on opt-in builds. Software that is not rebuilt, and data formats with 32-bit fields, remain exposed.

Limits of this guide

  • Only what could be reproduced or read at its source is stated. The MySQL limit, kernel statements and file-system ranges come from the cited documents and were not run.
  • Behaviour of other languages, databases and embedded toolchains is not covered. Check each against its own documentation.
  • The C example uses a defined unsigned-to-signed conversion; real programs that overflow signed integers directly have undefined behaviour.

Tested

Run on 2026-11-17 on Ubuntu 24.04 under WSL (glibc 2.39, GCC 13.3.0 with gcc-multilib), Python 3.11, Node.js 25.8, SQLite 3.50.4 and Windows PowerShell 5.1. The boundary dates were computed with Python datetime and cross-checked with GNU date -u -d, Node.js Date and .NET DateTimeOffset.FromUnixTimeSeconds; all matched. Not run: MySQL or any other database server, a real 32-bit machine or kernel (the -m32 builds ran on a 64-bit kernel), and file-system range claims.

Sources

Related tools

Written by Mian Ali Khalid. More guides in Dev Productivity.