The Messenger of Allah ﷺ only forbade deliberately timing one's prayer to coincide with the rising or setting of the sun.
حدثنا يحيى بن إسحاق حدثنا وهيب قال حدثنا ابن طاوس عن أبيه
إنما نهى رسول الله ﷺ عن الصلاة أن يتحرى بها طلوع الشمس وغروبها
Its isnad is sahih, mentioned previously at .