How does BIOS know what time it is?

How does the BIOS screen of a brand new motherboard (with no OS yet installed) know the correct local time and date?

Non-volatile memory powered by a CMOS battery.

Meaning the info is programmed at the time of manufacture and maintained by the battery? But what if the MB is manufactured in a time zone different from the one it is used in?

Ah I see what you mean. My guess is that they knew what time zone the motherboard would be sent to originally and programmed it accordingly.

There isn’t anything mysterious about it. The BIOS is a very primitive operating system on its own. The CMOS battery allows it to keep its own time and it can be very wrong if the battery runs out (that generally takes years) or if the time is set incorrectly in the first place. There is no GPS type functionality for timekeeping on any common PC’s that I am aware of and I have sent thousands of them into corporate use over the years and diagnosed the bad ones that came back.

The reason the BIOS knows the time at all is because it was set up that way and the battery maintains the clock for as long as it lasts. If you take a motherboard to a different timezone (I have many times), it will show the incorrect time. If the battery goes or if you have an a defective motherboard, the time will be incorrect as well. The only reason that it knows your time at all for a new motherboard is because the manufacturer set it that way in the first place. If it happens to go to somewhere other than originally intended, it will be wrong until someone resets it.

I guess. But that means that motherboard sellers would have to have their stock sorted by time zones and ship accordingly. There are only 4 time zones in the U.S., but worldwide, a lot more.

Some things I’ve always wondered but never asked:

What kind of battery does it have, anyway?
Does it get “recharged” in some way?
And will it let you know before it dies?
Is there a way to check it?

  1. It is like a large watch battery on the motherboard. It is fairly easy to see if you open your computer and know where to look. They are usually attached by light springs and are readily replaceable with just a butter knife and your fingers. There are many different variants but Radio Shack or online retailers can sell you a new one for a few dollars once you pull yours and look at the numbers on it.

  2. Yes, it is recharged from the motherboard power.

  3. They tend to die slowly at the 5 - 8 year old mark and cause some weird symptoms. The inability to keep correct time is one of them.

  4. You could probably check it in advance if you have the equipment but they are cheap and easy to replace. Most people just wait until they die and then pop in a replacement.

I don’t know how manufacturers sort out which motherboards go to where but it isn’t a very important issue. The real operating system (Windows, Linux etc.) is the only thing most end users are interested in. Once you have the OS installed, it cross-talks with the BIOS to keep the time updated even if there is a battery failure. A CMOS battery failure can and will cause some odd symptoms but the computer will still generally be functional. Having the motherboard set to an incorrect timezone from the factory isn’t much of a concern because the OS will generally correct it as soon as the end user sets it manually or it connects to the internet and syncs with a timeserver.

Also, Daylight Savings Time. Today the BIOS of a brand new board displayed the correct time (and date) on the east coast of the U.S. But if I had bought and installed the board a few months ago (during Eastern Standard Time) it would have been an hour off?

I realize it is not an important issue in terms of your computer’s performance, but it was surprising to see that the info was correct when the motherboard was first fired up.

Opps ! someone beat me to it

:slight_smile:

That’s OK, I just realized you go a part of the question right that I did not except under some very specific circumstances. CMOS batteries are basically just watch batteries and generally NOT rechargeable like you said according to the reading I just did on it. They last for years but it does not matter if the motherboard is powered on or off during that time.

Well, however it wound up set to the correct date/time for your time zone initially, once set then it would also be able to keep up with DST changes for your time zone too.

But as to how it was set correctly for your locale initially, my guess is still that they knew the time zone it would be sent to and programmed it that way. Otherwise, perhaps coincidence. The US EST zone is a pretty significant sector of the US market. The board manufacturers surely keep track of at least which country a given batch of boards will be going to, if not individual states.

One subtle point. Any Unix derived OS (Linux, Mac OSX) will use UTC in the system clock. The operating system never uses local time for any internal time functions. Conversion to local time only occurs when you want to display the time, and is based upon the setting of the TZ environment variable, or the contents of /etc/localtime. Both of which eventually resolve to a zoneinfo file that describes exactly how to translate any* UTC value to the correct local time. So more than correcting for the current time, the zoneinfo system is able to correctly display the local time, taking into account time offset from UTC and daylight savings offsets, for any date - including taking into account changes in the daylight savings offset in different years.

Bottom line is that if you are using Linux or Max OSX the time should always work.

  • For any value of UTC after the epoch - which is 1[sup]st[/sup] Jan 1970 - and before the clock wraps (which depends upon your exact OS.)

I’ve ordered mother boards that were off by an hour, so apparently they aren’t always set for the final time zone. I assume the manufacturer just sets them for whatever regional distribution center they get shipped off to, and from there its just luck.

Including those in laptops?

Absent a cite, in my personal experience most motherboards don’t actually ship with the correct timezone (or time). They’re usually way off, both in hours and minutes. But once Windows boots for the first time, it automatically grabs the Internet time and resets your BIOS clock to the right time for you.

Yeah, they’re not rechargeable. On older motherboards this can cause issues like with HTTPS, which relies on accurate times for the certificates, etc. I used to refurbish old computers and we’d have to manually reset the clock every bootup or the system wouldn’t work right (until we found a suitable replacement coin battery, obviously).

Yeah. Laptop CMOS batteries on Google Images.