Particle-counting statistics of time- and space-dependent fields