Variability in neural responses is a ubiquitous phenomenon in neurons, usually modeled with stochastic differential equations. In particular, stochastic integrate-and-fire models are widely used to simplify theoretical studies. The statistical properties of the generated spikes depend on the stimulating input current. Given that real sensory neurons are driven by time-dependent signals, here we study how the interspike interval distribution of integrate-and-fire neurons depends on the evolution of the stimulus in a quasistatic limit. We obtain a closed-form expression for this distribution, and we compare it to the one obtained with numerical simulations for several time-dependent currents. For slow inputs, the quasistatic distribution provides a very good description of the data. The results obtained for the integrate-and-fire model can be extended to other nonautonomous stochastic systems where the first passage time problem has an explicit solution.