The differential equations of motion of a charged particle in a strong non-uniform magnetic field have the magnetic moment as an adiabatic invariant. This quantity is nearly conserved over long time scales covering arbitrary negative powers of the small parameter, which is inversely proportional to the strength of the magnetic field. The numerical discretisation is studied for a variational integrator that is an analogue for charged-particle dynamics of the Störmer-Verlet method. This numerical integrator is shown to yield near-conservation of a modified magnetic moment and a modified energy over similarly long times. The proofs for both the continuous and the discretised equations use modulated Fourier expansions with state-dependent frequencies and eigenvectors.