Jareer bin Abdullah reported,

We were sitting with the Messenger of Allah ﷺ when he looked at the moon on the night of the full moon and said, "You will see your Lord just as you see this moon, with no difficulty in seeing Him. So if you are able not to be overcome from praying before the rising of the sun and before its setting, then do so." Then he recited, "And glorify the praise of your Lord before the rising of the sun and before its setting" [Qaf 50:39].

Ibn Majah 177

Sahih

حدثنا محمد بن عبد الله بن نمير حدثنا أبي ووكيع ح و حدثنا علي بن محمد حدثنا خالي يعلى ووكيع وأبو معاوية قالوا حدثنا إسمعيل بن أبي خالد عن قيس بن أبي حازم

عن جرير بن عبد الله قال

كنا جلوسا عند رسول الله ﷺ فنظر إلى القمر ليلة البدر قال إنكم سترون ربكم كما ترون هذا القمر لا تضامون في رؤيته فإن استطعتم أن لا تغلبوا على صلاة قبل طلوع الشمس وقبل غروبها فافعلوا ثم قرأ {وسبح بحمد ربك قبل طلوع الشمس وقبل الغروب}

ابن ماجه 177صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Sunnah
Chapter
What the Jahmiyyah denied
Numbering
Darussalam 177
Ibn Majah 177