It wasnarrated from Abu Dharr that the Prophet (ﷺ) said:
"Offerprayeron time, and if you reached the Imam leading them in prayers(ontime), then perform it with them, and you will be safe with yourprayer, otherwise it will be voluntary for you." (DE)
English reference (DE): Vol. 1, Book 5, Hadith 1256 (DE)
Arabic reference (DE): Book 5, Hadith 1314 (DE)