We don't know yet when most of the stars formed, what types of galaxies they formed in, or even when and how the galaxies formed. Some indications are coming in, but we have a ways to go. Most galaxies fall into two broad categories. Elliptical galaxies generally have almost no gas, and almost no star formation. Although they may have been spectacular in the past, they now appear to be relatively quiescent.
Spiral galaxies have gas and exhibit star formation.
For ellipticals, the question is kind of moot. The answer to the question for typical spirals is usually many billions of years, and sometimes over 10 billion years. For starburst galaxies, the answer is less than 1 billion years. In other words, starburst galaxies are consuming their gas quickly compared to the age of the universe. The fainter you look, the more stars and galaxies you see.