GameParticles
Date & time

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 valueBinary (32 bits)Date and time (UTC)
2,147,483,6460111...1110Tue 19 Jan 2038, 03:14:06
2,147,483,6470111...1111Tue 19 Jan 2038, 03:14:07
-2,147,483,6481000...0000Fri 13 Dec 1901, 20:45:52
-2,147,483,6471000...0001Fri 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 TIMESTAMP column type stores a 32-bit epoch value and tops out at 2038-01-19 03:14:07 UTC. Epoch seconds stored in a plain 32-bit INT column 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 | 0 to 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

StorageLast representable moment (UTC)
Signed 32-bit seconds19 January 2038, 03:14:07
Unsigned 32-bit seconds7 February 2106, 06:28:15
Signed 64-bit secondsAbout 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_t has 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_t for 32-bit builds in version 2.34 (2021) through the _TIME_BITS=64 setting, and musl switched to 64-bit time_t on 32-bit targets in version 1.2.0 (2020).
  • Distributions. Debian moved most of its 32-bit ports to 64-bit time_t for the Debian 13 release.
  • BSD. OpenBSD and NetBSD moved to 64-bit time_t on 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 BIGINT for epoch values and date types with a wide range, such as DATETIME in MySQL or timestamp in 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

  1. Search for epoch values stored in 32-bit types: int, int32_t, long on 32-bit targets, and INT columns.
  2. Check binary formats and protocols you own for four-byte time fields.
  3. Test with future dates. Set a test system's clock past January 2038, or feed timestamps such as 2147483648 and 4102444800 (1 January 2100) through your code.
  4. Check date arithmetic that looks far ahead: expiry dates, schedules, retention periods and financial terms.
  5. 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.

Tools in this guide

Frequently asked questions

What is the year 2038 problem?

Systems that store Unix time as a signed 32-bit integer can count no higher than 2,147,483,647 seconds after 1 January 1970. That limit is reached on 19 January 2038, after which the value overflows and the date jumps back to 1901.

What exact time does the 2038 problem happen?

The last second a signed 32-bit time_t can represent is 03:14:07 UTC on Tuesday 19 January 2038. One second later the counter wraps to its most negative value, which corresponds to 20:45:52 UTC on Friday 13 December 1901.

Will 64-bit computers be affected by the 2038 problem?

A 64-bit operating system with a 64-bit time_t is not affected at the system level. Individual programs, file formats, network protocols and database columns can still store time in 32 bits, so software on 64-bit hardware can carry the bug.

How is the year 2038 problem fixed?

By storing time in a signed 64-bit integer, which lasts about 292 billion years. That means a 64-bit time_t in the operating system and C library, recompiled applications, and wider fields in databases and file formats.

More date & time guides

JSON Formatter
Developer · Format, validate and minify JSON with syntax highlighting.
↵
Base64 Encode / Decode
Developer · Encode text to Base64 or decode Base64 back to plain text.
↵
URL Encoder / Decoder
Developer · Encode or decode URL components and query strings.
↵
Hash Generator
Developer · Generate MD5, SHA-1, SHA-256 and SHA-512 hashes.
↵
UUID Generator
Developer · Generate UUIDs v4 (random) in bulk with one click.
↵
Regex Tester
Developer · Test regular expressions against text with live match highlighting.
↵
Word Counter
Text · Count words, characters, sentences, paragraphs and reading time.
↵
Case Converter
Text · Convert text between UPPER, lower, Title, camelCase, snake_case and more.
↵
List Sorter
Text · Sort, reverse, deduplicate and shuffle lists of text.
↵
Markdown Preview
Text · Write Markdown and see a live rendered preview side by side.
↵
Percentage Calculator
Numbers · Calculate percentages, increases, decreases and what % one number is of another.
↵
Color Converter
Colors · Convert colors between HEX, RGB, HSL and HSV instantly.
↵
Snake
Arcade · Eat food, grow longer, don't hit the walls. A timeless classic.
↵
2048
Puzzle · Slide tiles and combine them to reach the legendary 2048 tile.
↵
Word Grid
Puzzle · Guess the hidden five letter word in six tries using color clues.
↵
Sudoku
Puzzle · Fill the 9x9 grid with logic. Four difficulties from easy to expert.
↵
Minesweeper
Strategy · Use number clues to clear the minefield. Classic logic, three levels.
↵
Breakout
Arcade · Smash every brick with paddle and ball. Power-ups, combos, endless levels.
↵
Typing Practice
Casual · Build your WPM and accuracy with timed drills from 30 seconds to 5 minutes. Find your weak keys.
↵
TypeRunner
Arcade · Multiplayer typing race. Race friends by link, beat computer runners, or chase your own ghost.
↵
Typing Blocks
Arcade · Type each word before its wooden block lands. Miss, and the pile climbs toward the line.
↵
Bubble Shooter
Arcade · Aim, bank shots off the walls, and pop groups of three or more bubbles.
↵
Road Rush
Arcade · Race seven rivals through traffic and punch your way to the front.
↵