The Prophet ﷺ stayed in Mecca for fifteen years. For seven of those years he would see light and hear a voice, and for eight years revelation came to him. Then he stayed in Medina for ten years.
حدثنا عفان حدثنا حماد بن سلمة أخبرنا عمار بن أبي عمار
أقام النبي ﷺ بمكة خمس عشرة سنة سبع سنين يرى الضوء ويسمع الصوت وثماني سنين يوحى إليه وأقام بالمدينة عشر سنين