The Prophet ﷺ said, "Do not pray when the sun is rising, nor when it is setting, for it rises between the two horns of Satan and sets between the two horns of Satan."
عن النبي ﷺ قال: لا تصلوا حين تطلع الشمس، ولا حين تسقط، فإنها تطلع بين قرني شيطان، وتغرب بين قرني شيطان.
Imam Ahmad (20169), Bazzar in Kashf Astar (612), and Tabarani in Al-Kabir (6973) all narrated it through the route of Shuba, from Simak bin Harb, who said, I heard Muhallab bin Abu Sufra narrating from Samura, and he mentioned the hadith. In another narration, he was giving a sermon and said, Samura bin Jundab said, and he mentioned the hadith. Ibn Khuzayma graded it sahih (1274) and narrated it through the route of Shuba in the same manner.I say, its chain is hasan because of Simak bin Harb, about whom there is some discussion, though his hadith is hasan.In another narration, the Messenger of Allah ﷺ used to command us to pray at whatever hour we wished, night or day, except that he commanded us to avoid the rising of the sun and its setting, and he said, "Satan disappears with it when it sets, and rises with it when it rises." Bazzar (610) narrated it from another route, from Khubayb bin Sulayman, from his father Sulayman bin Samura, from Samura bin Jundab, who mentioned something similar.He also narrated it from another route, from the hadith of Ismail bin Muslim, from Hasan, from Samura, that the Prophet ﷺ said, "Do not deliberately time your prayers with the rising of the sun or its setting, for it rises between the horns of a devil and sets between the horns of a devil." He said, We do not know of anyone who narrated the hadiths of Ismail from Hasan other than him.Haythami said in Al-Majma (2/225), Ahmad, Bazzar, and Tabarani in Al-Kabir narrated it through several routes, and the men of Ahmad's chain are trustworthy.