  The formation histories of globular clusters (GCs) are a key diagnostic for
understanding their relation to the evolution of the Universe through cosmic
time. We use the suite of 25 cosmological zoom-in simulations of present-day
Milky Way-mass galaxies from the E-MOSAICS project to study the formation
histories of stars, clusters, and GCs, and how these are affected by the
environmental dependence of the cluster formation physics. We find that the
median lookback time of GC formation in these galaxies is ${\sim}10.73~$Gyr
($z=2.1$), roughly $2.5~$Gyr earlier than that of the field stars
(${\sim}8.34~$Gyr or $z=1.1$). The epoch of peak GC formation is mainly
determined by the time evolution of the maximum cluster mass, which depends on
the galactic environment and largely increases with the gas pressure. Different
metallicity subpopulations of stars, clusters and GCs present overlapping
formation histories, implying that star and cluster formation represent
continuous processes. The metal-poor GCs ($-2.5<[\rm Fe/H]<-1.5$) of our
galaxies are older than the metal-rich GC subpopulation ($-1.0<[\rm
Fe/H]<-0.5$), forming $12.13~$Gyr and $10.15~$Gyr ago ($z=3.7$ and $z=1.8$),
respectively. The median ages of GCs are found to decrease gradually with
increasing metallicity, which suggests different GC metallicity subpopulations
do not form independently and their spatial and kinematic distributions are the
result of their evolution in the context of hierarchical galaxy formation and
evolution. We predict that proto-GC formation is most prevalent at $2\lesssim z
\lesssim 3$, which could be tested with observations of lensed galaxies using
JWST.
