2038: Y2K, Unix, and the end of time
Aug 23, 2020
7 seconds after 3:14am on January 19th, 2038 technology across the world will break.
Programming with dates and time is a gross experience. Most programmers will eventually learn of this pain and all the bugs waiting to take down their software.
These bugs tend to pop up the most when we’re dealing with time zones, leap dates, and overflow. Time zones and leap dates could each be separate essays on developer pain and anxiety,1 but for now let's talk about overflow. We’re going to specifically talk about the next Y2K known as the 2038 problem.
Why Y2K was a problem
Let’s clarify something: Y2K was a real problem, but it was blown out of proportion.2 When the new millennium rolled around a lot of existing bugs had been found and fixed. While some issues were missed, nothing was catastrophic. However, 2038 could be a bigger problem than Y2K.
Y2K was an issue because of how computers store dates. The problem with Y2K was the years rolling over from 98, 99 ➡️00. This is going to be the same problem in 2038 but the number we use to track time will be the root of the problem.
The Unix timestamp
Practically all computers track time with the Unix timestamp. This is a counter that started on January 1st 1970 and has been ticking every second since then.
The current Unix timestamp: 1,601,146,124
Y2K was a known problem because we knew the date was going to roll over from 99 to 00. 2038 is also a known problem for the same reason. The key difference is the date won’t roll over, the number itself will.
In computers we store numbers as integers. Most of these numbers are "signed 32-bit integers". This means numbers in computers have a maximum value that can be stored in memory. The maximum value for a signed 32-bit integer is 2,147,483,647. This means when the unix timestamp gets close to that number it will reset like the Y2K date did and overflow. It’ll go from 2,147,483,646 to 2,147,483,647 to 0 (Technically it goes to -2,147,483,648, but 0 makes the point a little clearer).
Because this counter is tied to time, we can predict it will happen at exactly 3:14am and 7 seconds on January 19th, 2038 UTC.
A good way of thinking about this problem is to compare it to the Gangnam Style video bug.
At one point Gangnam style got so many views it broke the view counter. It went from 2.1 billion views to -2.1 billion views. This is because YouTube didn't have a number large enough that was capable of storing the view count for the video.
How will we fix this problem?
Luckily this problem is still 18 years away so no one cares about it right now. I'm guessing everyone will wait until the last minute and then scramble to fix everything.
A good fix for some groups will be to change how the number is stored. If the number can be stored as a 64-bit integer this will help the immediate issue. This doesn’t fix the problem though, it only kicks the can down the road. But, it kicks the can down 292 billion years from now... That's 20 times longer than the age of the universe so I think that will work.
Things will break
We may know about this problem almost two decades in advance, but because of the massive amount of software out in the world it will be impossible to prevent every bug.
A lot of tech is being built with the ability to avoid this problem. This is great, but older systems will still be vulnerable.
I expect this to be a lot like the millennium bug. There will be real problems and some overblown fear. But at the end of the day few people outside of the developers fixing the bug should be affected.
Seconds until Y2K38: 546,337,523
1. Leap seconds are a thing. They suck.
2. I remember the start of the millennium clearly. My family threw a great New Years Eve party. It was a great time a lot of people came over and prepared for the countdown. No one really seemed worried about the millennium bug bringing about the new apocalypse.
The clock started counting down: 4, 3, 2, 1—Pure darkness. The power cut out. Otherwise reasonable people quickly started to freak out. The only other thing you could hear above the worried fussing of the people in the party was one person laughing.
It was my dad. He had just flipped the circuit breaker.