The Messenger of Allah ﷺ said, "Do not pray at sunrise or at sunset, for the sun rises and sets between the horns of Satan. Pray during the times between as much as you wish."
قال رسول الله ﷺ: لا تصلوا عند طلوع الشمس ولا عند غروبها، فإنها تطلع وتغرب على قرن شيطان، وصلوا بين ذلك ما شتم.
Abu Yaala narrated it (4216, edited by Husayn Salim) from Muhammad bin Abdullah bin Numayr, who said, "Rawh told us, Usama bin Zayd told us, from Hafs bin Ubaydullah, from Anas," and he related it. Its isnad is hasan because of Usama bin Zayd, who is Laythi. This isnad has already been mentioned with the wording of the hadith of Anas.The Prophet ﷺ forbade prayer after Asr until the sun sets, and after Fajr until the sun rises. Bazzar narrated it.So did Anas narrate it with two wordings in two separate sittings, with each of Abu Yaala and Bazzar receiving one of them, or did he narrate it with two wordings in a single sitting, but each of them was content with only one wording? This latter possibility seems unlikely.As for Haythami, he combined the two wordings in Majma al-Zawaid (3359, edited by Muhammad Abdul-Qadir Ata), attributing part of it to Abu Yaala and part of it to Bazzar, though I did not find this in the old edition. He then cited each part separately in Kashf Astar (613) and in Maqsad Ali (345), and Ibn Hajar likewise did so in Matalib Aliyah (315), from Abu Yaala.As for what was narrated from Muhammad bin Huyayy bin Yaala bin Umaya, from his father, who said, "I saw Yaala praying before the sun rose, and a man said to him, or it was said to him, 'You are a man among the companions of the Messenger of Allah ﷺ, yet you pray before the sun rises?'" Yaala said, "I heard the Messenger of Allah ﷺ say, 'The sun rises between the two horns of a devil.'" Yaala said to him, "If it rises while you are engaged in the affair of Allah, that is better than it rising while you are heedless." This narration contains Muhammad and his father, both of whom are unknown.Imam Ahmad narrated it (17959) from Abu Asim, who said, "Abdullah bin Umaya bin Abu Uthman Qurashi told us," who said, "Muhammad bin Huyayy bin Yaala bin Umaya told us," and he related the same. Haythami said in Majma (2/226), "Ahmad narrated it, and it contains Huyayy bin Yaala, who is unknown."