This is what the Qoran says: (First it was put into Muhammed s mind/heart all at once)
Most glorified is the One who summoned His servant (Muhammad) during the night, from the Sacred Masjid (of Mecca) to the farthest place of prostration,* whose surroundings we have blessed, in order to show him some of our signs. He is the Hearer, the Seer.
*17:1 ``The Aqsa Masjid'' means ``the farthest place where there is prostration,'' . This verse informs us that Muhammad, the soul, was taken to the highest Heaven to be given the Quran (2:185, 44:3, 53:1-18, & 97:1).
سُبحٰنَ الَّذى أَسرىٰ بِعَبدِهِ لَيلًا مِنَ المَسجِدِ الحَرامِ إِلَى المَسجِدِ الأَقصَا الَّذى بٰرَكنا حَولَهُ لِنُرِيَهُ مِن ءايٰتِنا إِنَّهُ هُوَ السَّميعُ البَصيرُ
We have sent it down in a blessed night, for we are to warn.
إِنّا أَنزَلنٰهُ فى لَيلَةٍ مُبٰرَكَةٍ إِنّا كُنّا مُنذِرينَ
Your friend (Muhammad) was not astray, nor was he deceived.
ما ضَلَّ صاحِبُكُم وَما غَوىٰ
Nor was he speaking out of a personal desire.
وَما يَنطِقُ عَنِ الهَوىٰ
It was divine inspiration.
إِن هُوَ إِلّا وَحىٌ يوحىٰ
Dictated by the Most Powerful.
عَلَّمَهُ شَديدُ القُوىٰ
Possessor of all authority. From His highest height.
ذو مِرَّةٍ فَاستَوىٰ
At the highest horizon.
وَهُوَ بِالأُفُقِ الأَعلىٰ
He drew nearer by moving down.
ثُمَّ دَنا فَتَدَلّىٰ
Until He became as close as possible.
فَكانَ قابَ قَوسَينِ أَو أَدنىٰ
He then revealed to His servant what was to be revealed.
فَأَوحىٰ إِلىٰ عَبدِهِ ما أَوحىٰ
The mind never made up what it saw.
ما كَذَبَ الفُؤادُ ما رَأىٰ
Then it was released slowly ( So it can be memorised and written down) according to GOD s commands, using Gabriel:
Say, "Anyone who opposes Gabriel should know that he has brought down this (Quran) into your heart, in accordance with God's will, confirming previous scriptures, and providing guidance and good news for the believers."
قُل مَن كانَ عَدُوًّا لِجِبريلَ فَإِنَّهُ نَزَّلَهُ عَلىٰ قَلبِكَ بِإِذنِ اللَّهِ مُصَدِّقًا لِما بَينَ يَدَيهِ وَهُدًى وَبُشرىٰ لِلمُؤمِنينَ
Do not move your tongue to hasten it.
لا تُحَرِّك بِهِ لِسانَكَ لِتَعجَلَ بِهِ
It is we who will collect it into Quran.
إِنَّ عَلَينا جَمعَهُ وَقُرءانَهُ
Once we recite it, you shall follow such a Quran.
فَإِذا قَرَأنٰهُ فَاتَّبِع قُرءانَهُ
Then it is we who will explain it.
How long it took is written in history.(Really how long is irrelevant since GOD did not put iti n the Qoran.)