They use the ratio of oxygen isotopes in the water frozen into the ice layers. The heavier oxygen isotope, Oxygen-18, does not evaporate as water (H2O-18) from the ocean surface as normal oxygen, Oxygen-16, water (H2O-16). As temperature increases more H2O-18 evaporates and the ratio of H20-18 to H20-16 in the ice changes. The ratio has been calibrated to temperature and is used as an estimate of surface air temperature. It is not perfect, but it is the best estimation tool at present. The time is determined by the lines in the core produced by differences in winter and summer.
“It is not perfect, but it is the best estimation tool at present.”
Exactly. And that pretty much describes everything science tries to explain from the distant past.