All posts

#year 2038 problem#unix time#software bugs

The Year 2038 Problem: Will Computer Clocks Stop in 12 Years?

On January 19, 2038, 32-bit Unix clocks will overflow and the date will jump back to 1901. We explain the Year 2038 problem, its GPS rehearsal and how to protect your systems today.

The Year 2038 Problem: Will Computer Clocks Stop in 12 Years?
Contents 10

January 19, 2038, 03:14:07 UTC. One second later, the clocks of millions of devices around the world could stop showing 2038 and jump back to December 13, 1901. This is not science fiction. The Year 2038 problem is a real software bug that comes from the way computers count time, and its date is already on the calendar. Some systems are running into it today.

In short:

  • Many systems store time as "seconds since January 1, 1970" in a signed 32-bit integer.
  • That number can be at most 2,147,483,647, which is reached on January 19, 2038 at 03:14:07 UTC.
  • One second later the number overflows, turns negative, and the date becomes December 13, 1901.
  • Modern 64-bit systems are largely safe; the real risk lies in embedded devices, old database columns and software that already calculates dates beyond 2038.

How do computers count time?

Computers don't store a date like "September 30, 2026, 14:00" directly. Unix and the systems derived from it (Linux, macOS, Android, most servers) keep time as a single number: the number of seconds since 00:00:00 UTC on January 1, 1970. That starting point is called the Unix epoch, and the number itself is the Unix timestamp.

For example, the start of the day this post was published, September 30, 2026 00:00 UTC, is 1790726400 in Unix time. Dates, times and time zones are all calculated from this number. The method is simple, fast and universal; the only problem is the size of the box the number lives in.

Why exactly January 19, 2038?

For many years, the C type that holds time, time_t, was defined on many systems as a signed 32-bit integer. Since one of those 32 bits is used for the sign (plus or minus), the largest number that fits in the box is 2³¹ − 1, or 2,147,483,647.

Count 2,147,483,647 seconds from 1970 and you land on this moment: January 19, 2038, 03:14:07 UTC. Seen from today, that is less than 12 years away.

In the next second the number wants to grow by one, but the box is full. Like an old car's odometer rolling from 999,999 to 000,000, the number overflows and jumps to the smallest possible value, −2,147,483,648. The system reads this negative number as "seconds before 1970", and the date suddenly becomes December 13, 1901, 20:45:52 UTC.

You can see it on your own computer

You don't need special hardware to see this bug. If you have Python installed, these few lines show exactly where the limit is and what the overflow does:

import ctypes
from datetime import datetime, timedelta, timezone

epoch = datetime(1970, 1, 1, tzinfo=timezone.utc)

last_second = 2**31 - 1
print(epoch + timedelta(seconds=last_second))  # 2038-01-19 03:14:07+00:00

overflowed = ctypes.c_int32(last_second + 1).value  # one more second in a 32-bit box
print(overflowed)                                   # -2147483648
print(epoch + timedelta(seconds=overflowed))        # 1901-12-13 20:45:52+00:00

ctypes.c_int32 forces the number into a 32-bit box. The result is exactly what will happen inside old systems in 2038.

How is it different from Y2K?

The Y2K scare at the turn of the millennium came from storing years with two digits (99). 00 could be read as 1900 instead of 2000. The world spent years preparing and got through it largely without trouble, which also left many people thinking it had been an overblown panic.

The Year 2038 problem is sneakier in two ways:

  • It lives inside a number, not in text. With Y2K you could see and search for dates. In 2038 the problem hides inside compiled code and data types; the source code never says "2038".
  • It lives in embedded devices. A large share of affected systems aren't computers at all: vehicle control units, industrial equipment, cameras, routers and smart home products. Many stay in the field for 10 to 20 years and never get an update.

We've already had a rehearsal: GPS

You don't have to wait until 2038 to see what a counter overflow looks like in real life. GPS satellites carry the week number in their navigation message using only 10 bits. Ten bits can count at most 1024 weeks, so the counter resets roughly every 19.7 years.

The most recent reset happened on April 6, 2019. Unprepared receivers pushed their date 1024 weeks back, to August 1999. According to official GPS sources, some devices misbehaved on that date, others months before or after, and they had to be fixed with software or firmware updates. The Year 2038 problem is a far more widespread version of the same thing.

How can the 2038 problem show up today?

"There are 12 years left" may sound reassuring, but software doesn't need to reach that year to hit the limit. Any system that calculates dates in the future touches the boundary today:

  • Long-term contracts: A 15-year loan, insurance policy or lease schedule puts its end date beyond 2038.
  • Certificates and licenses: Certificates or license keys issued with long validity periods.
  • Scheduled jobs and caches: Code that picks a date far in the future to mean "never expires".
  • Database columns: According to MySQL's official documentation, the TIMESTAMP type ranges from 1970-01-01 00:00:01 UTC to 2038-01-19 03:14:07 UTC. An end date stored in this type cannot hold anything after 2038.

In other words, the problem isn't something that "arrives in 2038"; for some systems it is already inside.

Who is at risk and who is safe?

The good news: the software world has known about this for a long time, and important steps have been taken.

Area Status
64-bit operating systems (modern Linux, Windows, macOS) time_t is 64-bit; the limit is about 292 billion years away
32-bit Linux kernel Linux 5.6 (2020) is the first mainline kernel for 32-bit systems ready to run past 2038
glibc (C library) Since 2.34, 64-bit time on 32-bit systems via _TIME_BITS=64
Debian 13 "trixie" Moved to 64-bit time_t on all architectures except i386
MySQL TIMESTAMP column Still limited to 2038-01-19 03:14:07 UTC
Old embedded devices The riskiest group; most can't be updated

There is a critical detail here: updating the kernel alone isn't enough. As the Linux 5.6 announcement pointed out, all user-space software must be rebuilt with a 64-bit time_t. Running an old program on a new system doesn't automatically make it safe.

What should developers do today?

If you're starting a new project, protecting it against 2038 usually comes down to a few right choices:

  1. Don't squeeze time into a 32-bit integer. In Java, a cast like (int) (System.currentTimeMillis() / 1000) shrinks a safe 64-bit value to 32 bits with your own hands. Use long or java.time.Instant.
  2. Pick the right database type. In MySQL, consider DATETIME instead of TIMESTAMP for columns that must hold dates after 2038. PostgreSQL's timestamp types already cover a range of thousands of years.
  3. Check file and network formats. Protocols and binary file formats that write timestamps into a 4-byte field bring the limit back even if your application is 64-bit.
  4. Add post-2038 dates to your tests. Move the system clock forward or put dates like 2040 in your test data to catch problems early.
  5. Ask before buying devices. When choosing long-lived hardware (IoT, industrial control, in-vehicle systems), ask the vendor about 2038 compatibility.

Frequently asked questions

Will the 2038 problem affect my phone or computer?

Most likely not. Today's phones and computers use 64-bit processors and operating systems, where time is stored in 64 bits. The risk is in old 32-bit devices and embedded systems that never get updated.

How long will 64-bit time last?

A signed 64-bit seconds counter lasts about 292 billion years, roughly 20 times the current age of the universe. In practice the problem disappears completely.

Is the 2038 problem an overblown fear like Y2K?

Y2K passed smoothly because the world prepared for years. Preparation for 2038 is under way too, and modern systems are largely safe. But because of embedded devices that can't be updated and old data formats, real failures are inevitable if nothing is done.

Why does the counter start in 1970?

The Unix operating system was developed in the early 1970s, and its developers picked a recent, round starting point. That is how 00:00:00 UTC on January 1, 1970 became the "moment zero" of the computing world.

The Year 2038 problem is one of the best examples of how a small decision in software (how many bits a number gets) can grow decades later. If you want to build systems that are long-lived and future-proof, reach out to us through our enterprise software development page.

Sources

Source: dev.mysql.com

ShareLinkedInXWhatsApp
Need help with this?

If you would like to apply what this post covers to your own project, let’s look at it together.

Write to us
YE

Founder of EngerekTech. Builds web, mobile and enterprise software for businesses with Angular, Spring Boot and Flutter, and made the KPSS Düello and Kelime Kavanozu apps. On the blog he covers AI tools and software development as he uses them in his own projects.