Gamma-ray bursts (GRBs) are the most luminous explosions and can be detectable out to the edge of Universe. It has long been thought they can extend the Hubble diagram to very high redshifts. Several correlations between temporal or spectral properties and GRB luminosities have been proposed to make GRBs cosmological tools. However, those correlations cannot be properly standardized. In this paper, we select a long GRB sample with X-ray plateau phases produced by electromagnetic dipole emissions from central new-born magnetars. A tight correlation is found between the plateau luminosity and the end time of the plateau in X-ray afterglows out to the redshift $z=5.91$. We standardize these long GRBs X-ray light curves to a universal behavior by this correlation for the first time, with a luminosity dispersion of 0.5 dex. The derived distance-redshift relation of GRBs is in agreement with the standard $Lambda$CDM model both at low and high redshifts. The evidence of accelerating universe from this GRB sample is $3sigma$, which is the highest statistical significance from GRBs to date.