The Mori-Zwanzig projection operator formalism is a powerful method for the derivation of mesoscopic and macroscopic theories based on known microscopic equations of motion. It has applications in a large number of areas including fluid mechanics, solid-state theory, spin relaxation theory, and particle physics. In its present form, however, the formalism cannot be directly applied to systems with time-dependent Hamiltonians. Such systems are relevant in a lot of scenarios like, for example, driven soft matter or nuclear magnetic resonance. In this article, we derive a generalization of the present Mori-Zwanzig formalism that is able to treat also time-dependent Hamiltonians. The extended formalism can be applied to classical and quantum systems, close to and far from thermodynamic equilibrium, and even in the case of explicitly time-dependent observables. Moreover, we develop a variety of approximation techniques that enhance the practical applicability of our formalism. Generalizations and approximations are developed for both equations of motion and correlation functions. Our formalism is demonstrated for the important case of spin relaxation in a time-dependent external magnetic field. The Bloch equations are derived together with microscopic expressions for the relaxation times.The currently used form of the Mori-Zwanzig formalism faces the problem that it cannot be directly applied to systems with time-dependent Hamiltonians. Those, however, are relevant for a lot of scenarios including soft matter systems subject to time-dependent external driving forces [30,31] or nuclear magnetic resonance (NMR) measurements with rapidly varying electromagnetic pulses [21].If arising, time-dependent Hamiltonians can sometimes be treated as additional external perturbations [3]. This requires, however, that the perturbation is sufficiently small and couples to the macroscopic variables only. Generalizations of the projection operator method towards non-Hamiltonian dynamical systems have been developed by Chorin, Hald, and Kupferman [27,32]. Xing and Kim use mappings between dissipative and Hamiltonian systems [33] to apply projection operators in the non-Hamiltonian case [34]. The methods from Refs. [32][33][34], however, are not applicable to quantum-mechanical systems. Moreover, approximation methods commonly applied in the context of the Mori-Zwanzig formalism, such as the linearization around thermodynamic equilibrium [3], rely on the existence of a Hamiltonian.The Mori-Zwanzig formalism exists in a variety of forms. The original theory developed by Mori [1] can be applied to systems with time-independent Hamiltonians that are close to thermal equilibrium. A generalization towards systems far from equilibrium using timedependent projection operators has been presented by Robertson [35], Kawasaki and Gunton [36], and Grabert [3,7]. Recently, Bouchard has derived an extension of the Mori theory towards systems with time-dependent Hamiltonians [21] that can be applied close to equilibrium. What is still missing, however...