One way is by using relative dating which is determined by comparing it's placement to fossils in other layers of rock to tell how old or young it is compared to the other ones.
Another way is radioactive dating and this can be done by calculating the age of a sample based on the amount of remaining radioactive isotopes it contains.