The Prophet ﷺ said, "Whoever catches one rakah of the dawn prayer before the sun rises has caught the dawn prayer, and whoever catches one rakah of the afternoon prayer before the sun sets has caught the afternoon prayer."
حدثنا إسحق بن موسى الأنصاري حدثنا معن حدثنا مالك بن أنس عن زيد بن أسلم عن عطاء بن يسار وعن بسر بن سعيد وعن الأعرج يحدثونه
أن النبي ﷺ قال من أدرك من الصبح ركعة قبل أن تطلع الشمس فقد أدرك الصبح ومن أدرك من العصر ركعة قبل أن تغرب الشمس فقد أدرك العصر
Agreed upon (by Bukhari and Muslim). Bukhari narrated it in the Book of Prayer Times, Chapter on Whoever Catches a Rakat of Fajr, Hadith: 579, and Muslim in the Book of Mosques, Chapter on Whoever Catches a Rakat of a Prayer Has Caught That Prayer, Hadith: 608, from the hadith of Malik, through this route, and it is found in Muwatta 6/1 (Yahya's recension).There is also a narration on this topic from Ayesha [Muslim, Hadith: 609].