The diffuse extragalactic background light (EBL) is formed by ultraviolet (UV), optical, and infrared (IR) photons mainly produced by star formation processes over the history of the Universe and contains essential information about galaxy evolution and cosmology. The EBL also attenuates gamma-ray fluxes that travel cosmological distances through pair-production interactions, leaving a signature in the gamma-ray spectra of extragalactic sources. In this talk, we present a new determination of the evolving EBL spectral energy distribution using a novel approach purely based on galaxy data aiming to reduce current uncertainties on the higher redshifts and IR intensities. Our results are based in one of the most comprehensive and deepest multi-wavelength galaxy datasets ever obtained, which allow us to derive the overall EBL evolution up to z~6 and its uncertainties. We will also discuss the gamma-ray optical depths that are obtained from our EBL approximation, and how we can measure galaxy evolution and other cosmological properties such as the cosmic star-formation rate and the expansion rate of the Universe using gamma-ray observations of blazars.