When you disconnect your PC from power outlet, there is no way the computer can get power. It shuts off. But think, without any power source, is it possible to continue something keep running? If this would happen, it would have been a miracle.
Many of you might know, there is a small cell placed with all motherboards. No matter whether it is for a desktop or a notebook. So there is always a power source. When AC power goes off, this cell start delivering power to a critical component of BIOS. Thus BIOS is able to maintain the time by counting electrical pulses. We call it a real-time clock (RTC).
The concept of RTC in personnel computer was first introduced by IBM in its 2nd generation PC around 1984. These days almost every electronic gadget has RTC to keep accurate time.
In computer motherboards, the cell (a CMOS battery) which powers this RTC, are generally made up of lithium and have a lifespan of 4-10 years. The cell supplies 3V standby power to the motherboard in absence of main power. In modern systems however, in place of lithium cell, supercapacitors are being used.