In their most basic form, computers use electrical signals that are represented as 1's or 0's. A 1 meaning that there is an electrical signal and a zero meaning that there isn't an electrical signal.
A computer keeps track of time using a vibrating crystal oscillator. This crystal oscillator gives off a constant and precise frequency. The oscillator is powered by a small and weak CMOS battery on your motherboard that provides a constant electrical signal for up to three years.
So how can a computer use this oscillator along with binary (1s and 0s) to keep track of timers?
When an interval is set, a value of zero is given to the computer along with a threshold based on the length of the interval and the frequency of the oscillator.
threshold = length of interval in ms / 1000 * frequency of crystal in MHz
When the oscillator vibrates, it puts off an electrical signal (1) and triggers a binary calculation that adds 1 to to the initial binary number (the one that started at 0). Once the initial value passes the threshold, the binary function puts off a 1 indicating that the interval has been fulfilled. Depending on the operations that are done after the threshold is met, the interval may be reset, saved, altered, or deleted.
Helpful links:
https://www.youtube.com/watch?v=1gyCZIBk_88
https://www.computerhope.com/jargon/q/quartz.htm