Al-Hasan used to say: "If he realises it while the time of the prayer is still in, he should repeat it."