Density-functional theory of many-electron systems subjected to time-dependent electric and magnetic fields