Recently, the nonlinear electrodynamics (NED) has been gaining attention to generate primordial magnetic fields in the Universe and also to resolve singularity problems. Moreover, recent works have shown the crucial role of the NED on the inflation. This paper provides a new approach based on a new model of NED as a source of gravitation to remove the cosmic singularity at the big bang and explain the cosmic acceleration during the inflation era on the background of stochastic magnetic field. Also, we found a realization of a cyclic Universe, free of initial singularity, due to the proposed NED energy density. In addition, we explore whether a NED field without or with matter can be the origin of the late-time acceleration. For this we obtain explicit equations for H(z) and perform a MCMC analysis to constrain the NED parameters by using 31 observational Hubble data (OHD) obtained from cosmic chronometers covering the redshift range 0< z < 1.97; and with the joint-light-analysis (JLA) SNIa compilation consisting in 740 data points in the range 0.01<z<1.2. All our constraints on the current magnetic field give B_{0}sim 10^{-31}mathrm {cm^{-1}}, which are larger than the upper limit 10^{-33}mathrm {cm^{-1}} by the Planck satellite implying that NED cosmologies could not be suitable to explain the Universe late-time dynamics. However, the current data is able to falsify the scenario at late times. Indeed, one is able to reconstruct the deceleration parameter q(z) using the best fit values of the parameters obtained from OHD and SNIa data sets. If the matter component is not included, the data sets predict an accelerated phase in the early Universe, but a non accelerated Universe is preferred in the current epoch. When a matter component is included in the NED cosmology, the data sets predict a q(z) dynamics similar to that of the standard model. Moreover, both cosmological data favor up to 2sigma confidence levels an accelerating expansion in the current epoch, i.e., the Universe passes of a decelerated phase to an accelerated stage at redshift sim 0.6. Therefore, although the NED cosmology with dust matter predict a value B_{0} higher than the one measured by Planck satellite, it is able to drive a late-time cosmic acceleration which is consistent with our dynamical systems analysis and it is preferred by OHD and SNIa data sets.