Keeping track of time is essential for everyday behavior. Theoretical models have proposed a wide variety of neural processes that could tell time, but it is unclear which ones the brain actually uses. Low-level neural models are specific, but rarely explicate how cognitive processes, such as attention and memory, modulate prospective and retrospective timing. Here we develop a neurocomputational model of prospective and retrospective timing, using a spiking recurrent neural network. The model captures behavior of individual spiking neurons and population dynamics when producing and perceiving time intervals, thus bridging low- and high-level phenomena. When interrupting events are introduced, the model delays responding in a similar way to pigeons and rats. Crucially, the model also explains why attending incoming stimuli decreases prospective estimates and increases retrospective estimates of time. In sum, our model offers a neurocomputational account of prospective and retrospective timing, from low-level neural dynamics to high-level cognition.