Thanks to the discovery of radioactive elements, isotopes (variants of elements), and their half-lives (how quickly they decay), geologists can use radiometric dating to determine when igneous rocks formed.
So, for example, the Devonian layer is older than the Jurassic. Researchers use fossils to date the age of rocks relative to one another, with simpler life predating that which is more complex. But, thanks to plate tectonics and erosion, rocks from every time period can also get jumbled up and exposed on the surface. Under normal conditions, the deeper you go, the older the rock layer. Astronomy and geology share one big constant - time.