Comparison theorems in Lorentzian geometry and applications to spacelike hypersurfaces