The Messenger of Allah ﷺ said: He who finds (gets) a rak'ah of the afternoon (prayer) before the setting of the sun, he in fact gets (the full prayer), and he who gets a rak'ah of the morning (prayer) before the rising of the sun he in fact gets (the full prayer).
قَالَ رَسُولُ اللَّهِ ﷺ مَنْ أَدْرَكَ مِنَ الْعَصْرِ رَكْعَةً قَبْلَ أَنْ تَغْرُبَ الشَّمْسُ فَقَدْ أَدْرَكَ وَمَنْ أَدْرَكَ مِنَ الْفَجْرِ رَكْعَةً قَبْلَ أَنْ تَطْلُعَ الشَّمْسُ فَقَدْ أَدْرَكَ