How do electronic devices keep track of time without power?
They use a small backup battery, which you can read about on Wikipedia:


  Modern personal computer motherboards have a backup battery to run the real-time clock circuit and retain configuration memory while the system is turned off.


In computers this is usually called the "BIOS battery" and is generally a lithium cell such as a CR2032.  In the photo below it is circled in red:



This is the same for portable devices which have their own battery, for example a laptop.  You can prove this by removing the internal battery and seeing if it keeps the time.

So to answer your question they don't really keep time without power, they have a battery for it.