Abdullah bin Abbas reported,

The Messenger of Allah ﷺ remained in Makkah for fifteen years. For seven of those years he would hear a voice and see a light without seeing anything else, and for eight years revelation came to him. He then remained in Madinah for ten years.

Muslim 6104

Sahih

و حدثنا إسحق بن إبراهيم الحنظلي أخبرنا روح حدثنا حماد بن سلمة عن عمار بن أبي عمار

عن ابن عباس قال

أقام رسول الله ﷺ بمكة خمس عشرة سنة يسمع الصوت ويرى الضوء سبع سنين ولا يرى شيئا وثمان سنين يوحى إليه وأقام بالمدينة عشرا

مسلم 6104صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Virtues
Chapter
How long the Prophet ﷺ stayed in Makkah and Madinah
Numbering
Darussalam 6104
Muslim 6104