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: over time, the metallicity of molecular clouds and stars has increased as nucleosynthesis within stars and supernovae has formed elements beyond hydrogen and helium. 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, 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.
Some particulars of the star imply a certain relative age: T-Tauri stars, protoplanetary disks, giant stars.