Most reconstruction algorithms used in photoacoustic tomography do not account for the effects of acoustic attenuation on the recorded signals. For experimental measurements made in biological tissue, the frequency dependent acoustic attenuation causes high frequency components of the propagating photoacoustic waves to be significantly reduced. This signal loss manifests as a depth dependent magnitude error and blurring of features within the reconstructed image. Here, a general method for compensating for this attenuation using time-variant filtering is presented. The time-variant filter is constructed to correct for acoustic attenuation and dispersion following a frequency power law under the assumption the distribution of attenuation parameters is homogeneous. The filter is then applied directly to the recorded time-domain signals using a form of nonstationary convolution. Regularization is achieved using a time-variant window where the cutoff frequency is based on the local time-frequency distribution of the recorded signals. The approach is computationally efficient and can be used in combination with any detector geometry or reconstruction algorithm. Numerical and experimental examples are presented to illustrate the utility of the technique. Clear improvements in the magnitude and resolution of reconstructed photoacoustic images are seen when acoustic attenuation compensation is applied.