There is only a star we are pretty sure we've got the right age for, and that is the Sun. Getting that value for every other star, from the very young to the very old, is a matter of clever modeling that tries to fit stars into a nice neat mold. And while it works often, it is far from perfect and is ultimately down to how much we know about the stars. Even when it comes to our own Sun, there is plenty we do not know.
But the age of stars is an important factor to know, and theoretically it is quite easy to work out what you need to look for. It’s in practice that it becomes difficult.
For most of the lifetime of a star, it will be fusing hydrogen, and how long that lasts depends on the mass of the star – but not in an obvious way.
Massive stars have more fuel to burn, but they also radiate a lot more energy. To not collapse on themselves, they need to be fusing a lot more than a star like the Sun, so they will go through said fuel in a much shorter time. Smaller stars will instead take things more slowly, as they do not have to burn through their fuel as quickly to maintain their internal equilibrium.
Based on this, you can see there is a law that connects the age to the mass of a star. This is a useful way to get to some type of estimate. It is important to know that no matter the size, when a star begins to release energy due to internal nuclear fusion of hydrogen, it will belong to a group called the main sequence.
The term comes from the distribution of these stars on the Hertzsprung–Russell (HR) diagram. On the vertical axis is the luminosity of these objects, and on the other the color index (or temperature, or stellar classification). The blue-white stars are the biggest and hottest, in the top left, and the red dwarfs are in the bottom right. The Sun is somewhere in the middle. When stars move off the main sequence they become red giants (and then supergiants), so their luminosity tends to stay the same but their color changes. All this can be useful when it comes to estimating their ages.
If you have a group of stars in a cluster, they likely formed at roughly the same time as each other. You will have a larger number of small stars than big ones, but at year zero you would expect to have them all in the main sequence.
Now, if you go and check on them a certain time later, a certain number of them will have moved off the main sequence. By plotting them on the HR diagram you can find the turnoff point. If in this cluster that point was a star like the Sun, you’d guess that the cluster is about 10 billion years old, since that’s how long the Sun is expected to stay on the main sequence.
Obviously, this approach would not be useful if you had an individual star. To try and gain some idea, another technique can be helpful: asteroseismology. This approach looks at the oscillations within the stars to gain insights. Stars turn hydrogen into helium, so an older star is going to have more helium and sound waves will propagate differently. And from that, age can be assumed.
There are also methods that looked at the rotation of a star, and from that infer an age. This appears to work for the low-mass main sequence stars. For stars too young to be in the main sequence, it is possible to guess an age based on the presence of material around them, or their variability before they settle into a “calmer” main sequence phase.
These methods directly or indirectly rely on what we know of the Sun. The more we learn about our little yellow star, the better we will understand all the stars in the Universe.