Messenger of Allah ﷺ said, "If anyone of you can get one rakʿa of the ʿAsr prayer before sunset, he should complete his prayer. If any of you can get one rakʿa of the Fajr prayer before sunrise, he should complete his prayer."
قَالَ رَسُولُ اللَّهِ ﷺ إِذَا أَدْرَكَ أَحَدُكُمْ سَجْدَةً مِنْ صَلاَةِ الْعَصْرِ قَبْلَ أَنْ تَغْرُبَ الشَّمْسُ فَلْيُتِمَّ صَلاَتَهُ وَإِذَا أَدْرَكَ سَجْدَةً مِنْ صَلاَةِ الصُّبْحِ قَبْلَ أَنْ تَطْلُعَ الشَّمْسُ فَلْيُتِمَّ صَلاَتَهُ