The decay-time-dependent $CP$ asymmetry in $B^{0}_{s}to J/psi K^{+} K^{-}$ decays is measured using proton-proton collision data, corresponding to an integrated luminosity of $1.9,mathrm{fb^{-1}}$, collected with the LHCb detector at a centre-of-mass energy of $13,mathrm{TeV}$ in 2015 and 2016. Using a sample of approximately 117,000 signal decays with an invariant $K^{+} K^{-}$ mass in the vicinity of the $phi(1020)$ resonance, the $CP$-violating phase $phi_s$ is measured, along with the difference in decay widths of the light and heavy mass eigenstates of the $B^{0}_{s}$-$bar{B}^{0}_{s}$ system, $DeltaGamma_s$. The difference of the average $B^{0}_{s}$ and $B^{0}$ meson decay widths, $Gamma_s-Gamma_d$, is determined using in addition a sample of $B^{0} to J/psi K^{+} pi^{-}$ decays. The values obtained are $phi_s = -0.083pm0.041pm0.006,mathrm{rad}$, $DeltaGamma_s = 0.077 pm 0.008 pm 0.003, mathrm{ps^{-1}}$ and $Gamma_s-Gamma_d = -0.0041 pm 0.0024 pm 0.0015,mathrm{ps^{-1}}$, where the first uncertainty is statistical and the second systematic. These are the most precise single measurements of these quantities to date and are consistent with expectations based on the Standard Model and with a previous LHCb analysis of this decay using data recorded at centre-of-mass energies 7 and 8 TeV. Finally, the results are combined with recent results from $B^{0}_{s}to J/psi pi^{+} pi^{-}$ decays obtained using the same dataset as this analysis, and with previous independent LHCb results.