A measurement is presented of decay-time-dependent CP violation in the decays B0 → J/ψ KS 0 and B0 → ψ(2S)KS 0, where the J/ψ is reconstructed from two electrons and the ψ(2S) from two muons. The analysis uses a sample of pp collision data recorded with the LHCb experiment at centre-of-mass energies of 7 and 8 TeV, corresponding to an integrated luminosity of 3 fb−1. The CP -violation observables are measured to beC(B0→J/ψKS0)=0.12±0.07±0.02,S(B0→J/ψKS0)=0.83±0.08±0.01,C(B0→ψ(2S)KS0)=−0.05±0.10±0.01,S(B0→ψ(2S)KS0)=0.84±0.10±0.01,where C describes CP violation in the direct decay, and S describes CP violation in the interference between the amplitudes for the direct decay and for the decay after B0− B¯ 0 oscillation. The first uncertainties are statistical and the second are systematic. The two sets of results are compatible with the previous LHCb measurement using B0 → J/ψ KS 0 decays, where the J/ψ meson was reconstructed from two muons. The averages of all three sets of LHCb results areC(B0→[cc¯]KS0)=−0.017±0.029,S(B0→[cc¯]KS0)=0.760±0.034,under the assumption that higher-order contributions to the decay amplitudes are negligible. The uncertainties include statistical and systematic contributions.[Figure not available: see fulltext.].