Abu Dharr reported,

The Prophet ﷺ said, "Pray the prayer at its proper time. If you then find the imam leading the people in prayer, pray with them, for you will have already secured your prayer, and this second one will count as a voluntary prayer for you."

Ibn Majah 1256

Sahih

حدثنا محمد بن بشار حدثنا محمد بن جعفر حدثنا شعبة عن أبي عمران الجوني عن عبد الله بن الصامت

عن أبي ذر

عن النبي ﷺ قال صل الصلاة لوقتها فإن أدركت الإمام يصلي بهم فصل معهم وقد أحرزت صلاتك وإلا فهي نافلة لك

ابن ماجه 1256صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Establishing prayer and the sunnah regarding it
Chapter
What to do if they delay the prayer beyond its time
Numbering
Darussalam 1256
Ibn Majah 1256