Determining the age of rocks and fossils is difficult and not always possible.
One way, however, is Potassium–argon dating. If the rock has potassium in it, then there is a trick that will help. A small fraction of potassium atoms are radioactive and slowly decay to become argon atoms. Around half of them decay every 1.248 billion years. The basic assumption is that the argon trapped in the rock has all come from the decay of potassium.
By measuring the amount of potassium and argon in the rock, it’s possible to work out what fraction of the potassium atoms have decayed and hence how old the rock is.
The Earth is only around 4.5 billion years old – just under 4 ‘half-lives’ so in the oldest rocks roughly ½ x ½ x ½ x ½ = 1/16th of the original radioactive potassium remains. So by using this technique, one can date certain rocks right back to near the formation of the Earth.