One day the Prophet ﷺ asked, "Do you know where this sun goes?"They replied, "Allah and His Messenger know best."He said, "It travels on until it reaches its resting place beneath the Throne. Then it falls down in prostration and remains that way until it is told, 'Rise up, go back where you came from.' So it goes back, and in the morning it rises from its rising place. Then it travels on until it reaches its resting place beneath the Throne, and it falls down in prostration and remains that way until it is told, 'Rise up, go back where you came from.' So it goes back, and in the morning it rises from its rising place. Then it travels on, and people notice nothing strange about it, until it reaches that resting place of its beneath the Throne. Then it is told, 'Rise up, and in the morning rise from your place of setting.' So in the morning it rises from the west."Then the Messenger of Allah ﷺ said, "Do you know when that will be? That will be when 'no soul will benefit from its faith if it had not believed before, or earned good through its faith' [Anam 6:158]."
أن النبي ﷺ قال يوما: أتدرون أين تذهب هذه الشمس؟ قالوا: الله ورسوله أعلم. قال: إن هذه تجري حتى تنتهي إلى مستقرها تحت العرش. فتخر ساجدة، فلا تزال كذلك حتى يقال لها: ارتفعي ارجعي من حيث جئت، فترجع. فتصبح طالعة من مطلعها. ثم تجري حتى تنتهي إلى مستقرها تحت العرش، فتخر ساجدة، ولا تزال كذلك حتى يقال لها: ارتفعي ارجعي من حيث جئت، فترجع. فتصبح طالعة من مطلعها، ثم تجري لا يستنكر الناس منها شيئا حتى تنتهي إلى مستقرها ذاك تحت العرش. فيقال لها: ارتفعي، أصبحي طالعة من مغربك، فتصبح طالعة من مغربها. فقال رسول الله ﷺ: أتدرون متى ذاكم؟ ذاك حين {لا ينفع نفسا إيمنها لم تكن امنت من قبل أو كسبت في إيمنها خيرا} [سورة الأنعام: ١٥٨].
Bukhari reported it in the Beginning of Creation (3199), and Muslim in Faith (159), both from the hadith of Ibrahim bin Yazid Taymi, from his father, from Abu Dharr, who mentioned it, and the wording is Muslim's.In another version narrated by both of them, "That is the meaning of His saying, Most High, "And the sun runs its course to a resting place determined for it. That is the determination of the All-Mighty, the All-Knowing" [Yasin 36:38]."