Ibn 'Abbas reported that Messenger of Allah ﷺ stayed in Mecca for fifteen years (after his advent as a Prophet) and he heard the voice of Gabriel and saw his radiance for seven years but did not see any visible form, and then received revelation for ten years, and he stayed in Medina for ten years. (Using translation from Muslim 2353e)
أَنَّ رَسُولَ اللهِ ﷺ أَقَامَ بِمَكَّةَ خَمْسَ عَشْرَةَ سَنَةً ثَمَانِ سِنِينَ أَوْ سَبْعًا يَرَى الضَّوْءَ وَيَسْمَعُ الصَّوْتَ وَثَمَانِيًا أَوْ سَبْعًا يُوحَى إِلَيْهِ وَأَقَامَ بِالْمَدِينَةِ عَشْرًا