On the day of the Battle of the Trench, after the sun had set, Umar bin Khattab began cursing the disbelievers of Quraysh and said, "Messenger of Allah, I could hardly perform the afternoon prayer before the sun was about to set."The Messenger of Allah ﷺ replied, "By Allah, I have not prayed it either."So we went down with the Messenger of Allah ﷺ to Buthan. He performed ablution for the prayer and we did the same. Then he prayed the afternoon prayer after the sun had set, and after it he prayed the sunset prayer.
أخبرنا إسمعيل بن مسعود ومحمد بن عبد الأعلى قالا حدثنا خالد وهو ابن الحارث عن هشام عن يحيى بن أبي كثير عن أبي سلمة بن عبد الرحمن
أن عمر بن الخطاب يوم الخندق بعد ما غربت الشمس جعل يسب كفار قريش وقال يا رسول الله ما كدت أن أصلي حتى كادت الشمس تغرب فقال رسول الله ﷺ فوالله ما صليتها فنزلنا مع رسول الله ﷺ إلى بطحان فتوضأ للصلاة وتوضأنا لها فصلى العصر بعد ما غربت الشمس ثم صلى بعدها المغرب
Bukhari narrated it in the Book of Prayer Times, in the chapter "Whoever leads people in congregational prayer after its time has passed," hadith no. 596, and Muslim narrated it in the Book of Mosques, in the chapter "Evidence for those who say that the middle prayer is the Asr prayer," hadith no. 631, from the hadith of Hisham Dastawai, through the same chain, and it is also found in Al-Kubra, hadith no. 1289.