On the day of the Battle of the Trench, he began cursing the disbelievers of Quraysh and said, "Messenger of Allah, I could hardly pray Asr before the sun set."The Messenger of Allah ﷺ replied, "By Allah, I have not prayed it either."So we descended to Bathan, and the Messenger of Allah ﷺ performed ablution and we performed ablution. Then the Messenger of Allah ﷺ prayed Asr after the sun had set, and afterwards prayed Maghrib.
و حدثنا محمد بن بشار بندار حدثنا معاذ بن هشام حدثني أبي عن يحيى بن أبي كثير حدثنا أبو سلمة بن عبد الرحمن عن جابر بن عبد الله أن
يوم الخندق وجعل يسب كفار قريش قال يا رسول الله ما كدت أصلي العصر حتى تغرب الشمس فقال رسول الله ﷺ والله إن صليتها قال فنزلنا بطحان فتوضأ رسول الله ﷺ وتوضأنا فصلى رسول الله ﷺ العصر بعد ما غربت الشمس ثم صلى بعدها المغرب
Agreed upon (by Bukhari and Muslim). Muslim narrated it in the Book of Mosques, chapter on the evidence for those who say that the middle prayer is Asr, no. 631, from the hadith of Muaz bin Hisham, and Bukhari narrated it in the Book of Prayer Times, chapter on one who leads people in prayer after its time has passed, no. 596, from the hadith of Hisham Dastawai, with the same wording.