One way is to look at any fossils the rock may contain. If any of the fossils are unique to one of the geologic time periods, then the rock was formed during that particular time period. When you find layers of rocks in a cliff or hillside, younger rocks are on top of older rocks. The age of a rock in years is called the absolute age.
Geologists find absolute ages by measuring the amounts of certain radioactive elements in the rock.
When rocks are formed, small amounts of radioactive elements usually get included. Thus, the older a rock is, the greater the amount of daughter elements and the lesser the amount of parent elements are found in the rock. As shown in the diagram, uranium is trapped in a newly formed rock. As the rock ages, more and more of the uranium changes into lead. The age of the rock in years can be found by measuring the rate at which a parent element decays and then measuring the ratio of the amount of the parent element to the daughter element in the rock.