Variational approach to the time-dependent Schrödinger–Newton equations