Time is fairly complex subject but we are used to taking it for granted. One reason for that is that these days computers keep track of time for us so we rarely need to think about it. The way that they do this is very interesting and taking a look at how computers understand time can teach us a lot about what time is to us. What's more, in our look into the world of computer time, we'll uncover an impending disaster that is to the Y2K problem as Krakatoa is to the gentle rumblings of your stomach on a hungover morning.

In days past I recall time being something that needed my attention. The watch on my wrist would drift from the correct time over days and weeks, the VCR seemed to need to be constantly reminded how far time had travelled and twice a year I would be early or late to work by an hour. The devices around me all needed to be regularly told what the time was, which meant that I needed to be aware of the time in a way that is no longer required of me. The watch on my wrist is a smartwatch that gets the time from my phone (and indeed, most people don't even need watches), almost all the devices in my house are capable of working out the time for themselves and my phone will automatically shift when the hour change happens twice a year, saving me from the mocking laughter of my colleagues. In a job years back no-one would schedule meetings for me within an hour of work starting after an hour change, the expectation being that I would forget again... But computers are just machines full of zeroes and ones. What can they know of time? How do they keep track of it for us? To answer that let us first look at how we keep track of time.

Humans and time

There's no fundamental human need to have any understanding of time. When it starts to get dark we could go to bed. We could awake with the sun every day (and indeed we have evolved biology that makes this happen effortlessly), eat whenever we are hungry and go about our business without concerning ourselves with the passage of minutes and seconds. On a larger scale, if required of us, we could see the year's progress by keeping an eye on the temperature and weather. Looking at even larger passages of time is easy by seeing the changes in ourselves and those around us as people grow up, procreate and die. Humans did just this for most of their existence but as we started to clump together in societies it became more important to coordinate the efforts of lots of people. If one needs to perform a task with a number of others it helps that they can all show up together so no one is left waiting around. Understanding the progress through they year massively improves the efficiency of farming and helps us predict incoming conditions.

So we developed timepieces which generally fall into two main categories:

  1. egg timers
  2. rotating clocks

Egg timers

Egg timer

An egg timer is a device that measures the passage of time by how much sand has fallen. There are many variants on the theme (e.g. water clocks) but they all work on the same principle, which is to convert time's passage into a number that changes - in an egg timer's case that's the number of grains of sand that have fallen. You're unlikely to count the grains individually because egg timers aren't that accurate but you could easily mark notches on the side of the timer to work out roughly when minutes and hours have passed by.

One disadvantage to the egg timer approach is that you need to turn it over when it has finished. If you have a really big one, in theory you could have a timer that tracks the whole week, or if you were feeling particularly ambitious you could build one that has enough sand to measure an entire year!

Rotating clocks

Clock face

Rotating clocks are a jolly clever idea so it's no surprise they're pretty much ubiquitous and in fact they are just building on the principle of a sundial (which use the actual rotation of the Earth to tell the time). When an egg timer gets to the end of the sand it needs to be turned over, but rotating clocks solve this problem very neatly! They just keep on spinning and when the hand on the clock gets to the end it just keeps on going round - there's no need to turn it over or reset it in any way. This is an excellent way of tracking the passage of time. If you need to time something you can look at a clock that is always spinning and watch how long something takes.

But it isn't perfect. Consider a clock that only has a second hand. The clock is constantly going round counting the number of seconds for you so if you keep an eye on it you know the time very well without having to keep turning over an egg timer. But if you just glance at it from time to time this clock doesn't tell you much useful information.

A smart gentleman on the bus turns to you and asks the time. You consult your watch and reply warmly, "it's 3 seconds". He pauses for a moment and then turns back. He says nothing but you can see he is unsatisfied by your response.

This highlights the main difference between these two systems of time-telling. The rotating clock is better for the simple passage of time because it is always spinning without attention. The egg timer needs to be reset when it runs out but by resetting it you are aware that it has finished. By keeping track of the number of times you've turned it over you are aware of how much time has passed beyond what the timer itself can measure.

Are they so different?

Of course, the clock can (and did) strike back! The modern clock has a hand for seconds, another hand for minutes and a third for hours. This is much more useful because when the nice bus gentleman asks for the time you can tell him "3 seconds" but the minute hand has kept track of how many times the second hand has gone round so you can also tell him "58 minutes". On top of that, the hour hand knows that the minute hand has gone round 11 times since midday and so determining that he doesn't need to-the-second accuracy you can sing to him:

"Two! Minutes, to midnight!".

Watch face with date

A clock could even have additional hands for days, weeks and so on. Indeed it's not uncommon to see mechanical watches that include a little date on the face as well.

But as we mentioned above, you could also build a really big egg timer. Maybe one that holds enough sand to work for many decades. Then you could add a mechanism to it so it turns itself over when the sand is depleted. Now we have overcome the main benefit of the clock - it keeps going for ever. We also have the simplicity of keeping a single number (in the egg timer's case, the number of grains that have fallen) to measure time's passage. A similarly useful clock would need lots of hands going through months, years and decades. What's more, not all years are the same length! Months have varying lengths and in February's case it has a different length depending which year you are in. You can imagine how complex such a clock would have to be...


Computers take the large egg timer approach. Clocks in computers are just like an 80's digital watch, which is a tiny little computer completely dedicated to the goal of keeping and displaying the time for its wearer.


Digital watches generally have a crystal in them that vibrates very quickly when a small amount of electricity is run through it. For the sake of argument let's say that our watch vibrates 1000 times every second (it's actually probably more like 32,768. The watch will count these vibrations and for every one thousand vibrations it knows one second has passed. The vibrations are like grains of sand in the egg timer and seconds are markings up the side of the timer that let you see every thousand grains. What happens when you set the time will change from watch to watch but roughly speaking it will store when you said it was 23:58:03 on the 28th March 2014. Then when it counts the seconds after that it can just add them to what you said.

Knowing vs keeping the time

This is an important point because I think it's something that's easy to overlook until you start to investigate how computers manage time. "The time" as we know it is really split into two separate parts.

  1. Knowing the current time
  2. Keeping track of the time as it changes

Egg timers and clocks can do the latter but they both take a person to set them. When you buy a watch, how do you know what time to set it to? If your answer is "I look at another clock" (and obviously, it is) then the question becomes "how did you set that clock"? It's turtles all the way down.

Position of the Earth

But it is possible for us to know the time because time is a concept that humans have invented. "The time" is defined by a combination of the position of the Earth around the sun and direction it is facing. The former gives us the date in the year and the latter the time in the current day. Basically, we can tell the time by looking at the sun and stars. But egg timers, clocks and computers don't do that so they need something to tell them. most of our timepieces need to be set but complex computers like the one in your pocket on your desk are connected to the Internet and they will ask other computers for the time automatically. Those computers are incredibly accurate and have been carefully set by clever people. It's basically the talking clock for computers.

Real computers

So now I've gone and mentioned complicated computers let's look at them properly. Computers have a little digital watch like we described above in them, keeping track of the time even when the computer is off. The computer turns that egg timer into the time by asking someone (you or the Internet) for the current time just like the way you set a watch. Even advanced computers are just like the simplest egg timers. The reason they are so much more useful is that they can keep track of much larger amounts of time and that they can set themselves by asking for the time without your intervention.

Computers store all information as zeroes and ones. "The time" is just a number - it's the number of grains of sand that have fallen through the egg timer. By convention computers use "the number of seconds since the start of 1970" as the egg timer, it's called UNIX time because it was popularised by UNIX systems. The current value is 1396050995. Computers store numbers using binary:

0  =    0
1  =    1
2  =   10
3  =   11
4  =  100
5  =  101
10 = 1010
1396050995 = 1010011001101100000110000110011

Computers have generally used 32 bits to store the time. The first of these is used for the sign (to say if it is a positive or negative number) so that leaves 31 bits to store the number. That means that the egg timer used by computers can hold 31 bits worth of sand, which is 2147483648 seconds. I mentioned that computers use UNIX time, so for them the start of 1970 is the baseline for time. It's just as if the egg-timer inside started running at the start of 1970. When you (or the Internet) set the time on the computer you are telling it where it has got to and it will put the egg timer into the right state (currently 1396050995 seconds after 1970's start). so when does this virtual egg timer run out? Since a 32-bit computer can count up to 2147483648 seconds the egg timer will run out that many seconds after 1970, which is 03:14:08 on the 19th January 2038!



At 03:14:08 on the 19th January 2038 computers all over the world will suddenly jump back to a date in late 1901 when their egg timers turn over and start again from the beginning (it's late 1901 not 1970 because of the sign, it goes from 31bits right back to -31bits). This will cause some problems.

The "Millennium bug" turned out to not be as big a deal as many had feared. Partly that's because it was predicted in advance and lots of work was done to mitigate the issues. However, another reason it was so anticlimactic is that as we've seen computers don't count dates the same way we do. A computer doesn't care if it's 1999 or 2000 because it knows that the time is actually 946684800. Computers generally only muck about with our complicated dates when they need to show us something, which limited the kinds of issues that could crop up. Y2K38 is rather more serious because it deals with the fundamental way that computers store and deal with time.

Even now, modern general-purpose computers like your laptop or work computer will generally be using 64 bits to keep track of the time, probably a big enough egg timer to outlast the universe. Many computers won't have made this switch yet (your phone is still unlikely to use more than 32 bits) but computers like these are aimed at consumers and are unlikely to be the problem. For starters they probably aren't expected to last for the next 24 years. Computers are built into everything these days and it is the small, cheap, embedded computer that will most likely still be around to fail us.

Consider a hospital, where there are machines that regulate patients' morphine doses. They work by keeping track of when morphine is administered and how much to prevent overdoses. When the time jumps back the machine will happily say "oh, this person hasn't had any morphine today, fine to give them some more". Computers are built into transport networks all around us, running metro and train signals, traffic lights and so on. They monitor power plants and nuclear reactors, air-traffic control and motorway speed limits, factories and greenhouses. In these cases and more, any machines that aren't updated may fail when the egg timers inside them flip over and start again.

I'll be having a party on the 18th of January 2038 with a big celebratory countdown to the big moment. It's a long way away and no doubt through the diligent work of many people pretty much everything will be ready for the end of UNIX time. But it'll be fun to see what got missed...


Thanks for reading. This was a bit of ramble but I had fun thinking about it and coming up with a good way to explain it to a non-technical audience. I hope you found it useful.

If you're still interested there's plenty to read about but I'd suggest Wikipedia's article on Y2K38 and UNIX time as good places to start.