Question: How are computers able to tell the correct time and date every time?

Whenever I close the computer (shut it down) all connections and processes inside stop. How is it that when I open the computer again it tells the exact correct time? Does the computer not shut down completely when I shut it down? Are there some processes still running in it? But then how does my laptop tell the correct time when I take out the battery (and thus forcibly stop all processes) and start it again after a few days?

Answer: 
Computers have a "real-time clock" -- a special hardware device (e.g., containing a quartz crystal) on the motherboard that maintains the time. It is always powered, even when you shut your computer off. Also, the motherboard has a small battery that is used to power the clock device even when you disconnect your computer from power. The battery doesn't last forever, but it will last at least a few weeks. This helps the computer keep track of the time even when your computer is shut off. The real-time clock doesn't need much power, so it's not wasting energy. If you take out the clock battery in addition to removing the main battery and disconnecting the power cable then the computer will lose track of time and will ask you to enter the time and date when you restart the computer.

To learn more, see [Real-time clock](https://en.wikipedia.org/wiki/Real-time_clock) and [CMOS battery](https://en.wikipedia.org/wiki/Nonvolatile_BIOS_memory#CMOS_battery) and [Why does my motherboard have a battery](http://www.makeuseof.com/tag/why-does-my-motherboard-have-a-battery/).

Also, on many computers, when you connect your computer to an Internet connection, the OS will go find a time server on the network and query the time server for the current time. The OS can use this to very accurately set your computer's local clock. This uses the [Network Time Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol), also called NTP.
If you remove the battery on the motherboard then the computer wouldn't have any way to tell the time.

This is also the case with mobile phones. If you let a phone discharge and then not recharge it for more than a few weeks it will also "forget the time" because the small auxiliary battery is discharged completely and nothing is powering on the real-time clock.

You could try to power on an old mobile phone if you have one and check it yourself to see that it "forgot the time".

This is how the battery looks.
<https://yandex.com/images/touch/search?text=mobo%20battery&source=tabbar>

I had to buy one a few times when mine started to last less then a day. I had to configure the clock everytime i turned on the PC.