Stellar Age Determination is, at best, estimated. Some factors in the estimation:
Stellar Mass Determination: massive stars have a shorter lifetime, thus necessarily are relatively Young Stars, e.g., millions of years old rather than billions.
Stellar Rotation: stars are presumed to rotate due to angular momentum in the Molecular Clouds from which they form. They slowly lose this rotation as Stellar Wind carries away angular momentum, so a particular rotation rate is characteristic of a particular age. This method of estimation is called Gyrochronology.
Spectrographs for Metallicity (Z): over time, the metallicity of molecular clouds and stars has increased as Nucleosynthesis within stars and supernovae (SN) has formed elements beyond Hydrogen (H) and Helium (He). Stars whose spectra indicate no Metals are presumed to be old enough to be born in a time of lower metallicity, and vice versa.
Stellar clusters (e.g., Globular Clusters (GC), Open Clusters) are assumed to have formed stars over a relatively short period, thus the ages of some stars in the cluster (e.g., massive stars, necessarily young) implies a similar age for stars in the cluster that will have a longer lifetime.
Stellar Parameter Determination