Aside from the excellent points made in James K's answer, there are other ways to date craters. For example, when the rays of one crater overlay those of another, we know that the former is younger than the latter.
We can also estimate ages of large craters by counting subsequent craters inside the crater floor. Crater counting is one of the more common ways of estimating the age of lunar surface features.
We can also determine ages of some craters by looking at whether it was affected by known ancient lunar processes.
Then there is radiometric dating. Large impacts spread materials across the surface of the moon, so the Apollo mission samples contained ejecta from many craters, some of which are identifiable by things like mineral composition unique to that part of the moon.
Once you have a good date for one crater, you can use that data to help determine the age of others. For example, if the floor of a crater has X smaller craters in it, and you know how old that crater is, you can then use those counts to estimate ages of other craters with similar counts. With enough varied data sets, you can generate some pretty good functions for estimating absolute ages.
For example, have a look at the image of the Aristarchus Plateau below:
NASA (image by Lunar Reconnaissance Orbiter) [Public domain]
Notice the two craters at the bottom of the plateau. The one on the left is the crater Herodotus, and the one on the right is Aristarchus.
Looking at the differences between the two of them, the first thing you notice is that Herodotus is filled in with the same lava that fills the basin around the plateau, but Aristarchus does not have that fill. So right there we know that Herodotus pre-dates the event that filled in Oceanus Procellarum, while Aristarchus came later. This makes Herodotus at least 1.2 billion years old, which is the current best estimate for the last time lava flowed on the moon.
Now, we can do better than that with sampling. If we get a sample of the basalt inside Herodotus, we can use radiation dating to determine when it crystallized, and that would give us a very good upper limit of the age of the crater. And in fact we did get such samples from Apollo, and that, plus crater counting, plus looking at other features around it with known ages, plus the amount of degradation in the crater walls and the coloration of the material, we can tell that Herodotus dates to the Imbrium era, or about 3.8 billion years ago.
As for Aristarchus crater, you can see lots of evidence that it is young. For one thing, its interior and ejecta are incredibly bright - it's the brightest crater on the moon. We know from radiological dating and crater counting that similarly bright craters are young. The walls of the crater have minimal slumping, and the ejecta around the crater is still well defined.
Aristarchus is one of the 'Copernican' craters, so named because they all formed during the Copernican period, which starts 1.2 billion years ago and goes right up to the present. Other large copernican craters include Copernicus, Tycho, and Kepler, among others.
Now look at this wider, high contrast image of the Tycho region. You can see Copernicus and Kepler on the right, and Tycho lower center. Note that the crater rays overlap each other, and by careful examination we can tell the order of the impacts. That helps us further refine the relative ages of the craters, and if we can narrow down the age of one with sampling or other techniques, it helps narrow down the ranges of the others.
Btw, the order of creation from oldest to newest Copernicus, Kepler, Aristarchus, Tycho.
Here's a pretty good reference describing a number of techniques for dating features on the moon:
Relative Crater Age Determination
This is an iterative process - each time you narrow down the age of a crater, that can be used as data to further refine the ages of others, But it's not a precise science - age estimates of various craters can still vary by hundreds of millions of years. There is still a lot we don't know about how the Moon formed and evolved.