It is narrated from Sayyiduna Ibn Abbas (may Allah be pleased with them both) (the narrator said: I think Hammad was in doubt about it) that he said: "The Prophet (peace and blessings be upon him) stayed in Makkah for fifteen years: for seven or eight years he would see the light and hear the voice, and for eight years revelation came down to him; and he stayed in Madinah for ten years."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 12785