Imām Bukhārī narrates: Musaddad narrated to us, he said: Yahyā narrated to us, from Ismā'īl, he said: Qais narrated to us, he said: Jarīr ibn 'Abdullāh, may Allāh be pleased with him, said to me that:
we were with the Prophet ﷺ; it was the night of the moon of the fourteenth. He looked towards the moon and said: Listen! Soon you will see your Lord just as you are seeing this moon; you will have no difficulty, nor will you have any doubt. So if you are able not to be overcome in praying before the rising of the sun and before the setting of the sun, then do this (surely). Then he recited this verse: "So glorify with the praise of your Lord before the rising of the sun and before its setting." (Ṭāhā: ).
حَدَّثَنَا مُسَدَّدٌ، قَالَ حَدَّثَنَا يَحْيَى، عَنْ إِسْمَاعِيلَ، حَدَّثَنَا قَيْسٌ، قَالَ لِي جَرِيرُ بْنُ عَبْدِ اللَّهِ كُنَّا عِنْدَ النَّبِيِّ صلى الله عليه وسلم إِذْ نَظَرَ إِلَى الْقَمَرِ لَيْلَةَ الْبَدْرِ فَقَالَ " أَمَا إِنَّكُمْ سَتَرَوْنَ رَبَّكُمْ كَمَا تَرَوْنَ هَذَا، لاَ تُضَامُّونَ ـ أَوْ لاَ تُضَاهُونَ ـ فِي رُؤْيَتِهِ، فَإِنِ اسْتَطَعْتُمْ أَنْ لاَ تُغْلَبُوا عَلَى صَلاَةٍ قَبْلَ طُلُوعِ الشَّمْسِ، وَقَبْلَ غُرُوبِهَا فَافْعَلُوا ". ثُمَّ قَالَ " فَسَبِّحْ بِحَمْدِ رَبِّكَ قَبْلَ طُلُوعِ الشَّمْسِ وَقَبْلَ غُرُوبِهَا ".
Reference: Sahih Al Bukhari 573