Some stars are as old as the the Universe (15 billion years), others have much shorter lifetimes (3 million years).
The first-generation stars were only made up of hydrogen and helium. These stars couldn't host solid planets!
The second-generation stars, formed in this interstellar medium, were made up of H, He, and a little bit of carbon (C), oxygen (O), nitrogen (N) and fluorine (F). The planets of these stars were made up of gas (H and He) and ices : water ice (H2O), CO ice, and CO2 ice . The heavy atoms formed by these stars are dispersed in the ISM. Only the stars of the next generations can have rocky and metal planets.
The Sun is 4.5 billion years old. It formed in a medium enriched by several generations of stars.
The Hubble Space Telescope observed a lack of planets around very old and metal-deficient (atoms heavier than He) stars, in the Toucan cluster.