The determination of the star-formation history of the Universe is a key goal of modern cosmology, as it is crucial to our understanding of how galactic structures form and evolve. Observations of young stars in distant galaxies at different times in the past have indicated that the stellar birthrate peaked some eight billion years ago before declining by a factor of around ten to its present value. Here we report an analysis of the `fossil record' of the current stellar populations of 96,545 nearby galaxies, from which we obtained a complete star-formation history. Our results broadly support those derived from high-redshift galaxies. We find, however, that the peak of star formation was more recent-around five billion years ago. We also show that the bigger the stellar mass of the galaxy, the earlier the stars were formed, which indicates that high- and low-mass galaxies have very different histories.