Were the Heavens and Earth Created in 6 or 8 Days?
Question

I read the verse in which Allah says (interpretation of the meaning): 
“Indeed, your Lord is Allah, Who created the heavens and the earth in Six Days, and then He rose over (Istawa) the Throne (really in a manner that suits His Majesty). He brings the night as a cover over the day, seeking it rapidly, and (He created) the sun, the moon, the stars subjected to His Command. Surely, His is the creation and commandment. Blessed is Allah, the Lord of the `Alamin (mankind, jinn and all that exists)!”
[Al-A’raf 7:54] 
What I understand from this is that Allah created the heavens and the earth in six days. This is clear. 
But in another passage Allah mentions the creation of the heavens and the earth, and He says (interpretation of the meaning): 
“Say (O Muhammad): Do you verily disbelieve in Him Who created the earth in two Days? And you set up rivals (in worship) with Him? That is the Lord of the `Alamin (mankind, jinn and all that exists).
He placed therein (i.e. the earth) firm mountains from above it, and He blessed it, and measured therein its sustenance (for its dwellers) in four Days equal (i.e. all these four `days’ were equal in the length of time) for all those who ask (about its creation).
Then He rose over (Istawa) towards heaven when it was smoke, and said to it and to the earth: `Come both of you willingly or unwillingly.’ They both said: `We come willingly.’
Then He completed and finished from their creation (as) seven heavens in two Days and He made in each heaven its affair. And We adorned the nearest (lowest) heaven with lamps (stars) to be an adornment as well as to guard (from the devils by using them as missiles against the devils). Such is the Decree of Him, the All-Mighty, the All-Knower”
[Fussilat 41:9-12]
 Here Allah says that He created the earth in two days, then He placed therein firm mountains and measured therein its sustenance in four days, which makes six days in all. Then He created the heavens in two days, so the total comes to eight days.
How can we reconcile between the two verses?
Praise be to Allah.This is an issue which confuses some people, and some of them think that Allah created the heavens and the earth in eight days as Allah says (interpretation of the meaning): 
“Say (O Muhammad): Do you verily disbelieve in Him Who created the earth in two Days? And you set up rivals (in worship) with Him? That is the Lord of the `Alamin (mankind, jinn and all that exists).
He placed therein (i.e. the earth) firm mountains from above it, and He blessed it, and measured therein its sustenance (for its dwellers) in four Days equal (i.e. all these four `days’ were equal in the length of time) for all those who ask (about its creation).
Then He rose over (Istawa) towards heaven when it was smoke, and said to it and to the earth: `Come both of you willingly or unwillingly.’ They both said: `We come willingly.’
Then He completed and finished from their creation (as) seven heavens in two Days and He made in each heaven its affair. And We adorned the nearest (lowest) heaven with lamps (stars) to be an adornment as well as to guard (from the devils by using them as missiles against the devils). Such is the Decree of Him, the All-Mighty, the All-Knower.” [Fussilat 41:9-12] because this seems to contradict the other verse which says that He created them in six days . 
This is a misunderstanding, and the answer to it is as follows: 
There is no contradiction between the time period mentioned in these verses and the other verse which says that it was six days. 
In these verses – from Surat Fussilat – we see that Allah is telling us that He “created the earth in two Days”.  
Then He “placed therein (i.e. the earth) firm mountains from above it, and He blessed it, and measured therein its sustenance (for its dwellers)” in four days equal– i.e., in two days that were added to the two days in which He created the earth, so the total is four days.  It does not say that the creation of the mountains and the measuring of the sustenance took four days. 
Perhaps the confusion which is mentioned in the question stems from this, i.e., from thinking that the four days are added to the two days in which the earth was created , equaling six, and then adding the two days in which the heavens were created (“Then He completed and finished from their creation (as) seven heavens in two Days ”) – making a total of eight days, not six days. But this confusion can be dispelled by dealing with this mistaken notion.  So the earth was created in two days, and the mountains were created and the sustenance measured in two more days which makes a total of four, i.e., this took the other two days. Then the creation of the seven heavens took two days. So the total is six days of the Days of Allah , may He be Glorified and Exalted. 
The commentators of the Quran commented on this fact which deals with the mistaken notion. Al-Qurtubi (may Allah have mercy on him) said: 
“in four days” – this is like someone saying, “I set out from Basra to Baghdad in ten days and to Kufa in fifteen days, i.e., a total time of fifteen days.” (Al-Jami` li Ahkam Al-Quran, vol. 15, p. 343). 
Al-Baghawi said: “in four days” means the creation of what is in the earth. The measuring of the sustenance was on Tuesday and Wednesday, which along with Sunday and Monday add up to four days. This is like saying “I married a woman yesterday and today I married two” – one of whom is the woman whom he married the day before.” (Tafsir Al-Baghawi, 7/165) 
Al-Zajjaj (may Allah have mercy on him) said: “in four days” means two days added to the previous two days.” (Al-Kashshaf, vol. 3, p. 444) 
These verses – from Surat Fussilat – confirm the other verse, which says that the creation of the heavens and the earth was completed in six days. So there is no contradiction concerning the period in which Allah created the heavens and the earth. There cannot be any such contradictions in the Quran.. 
And Allah knows best.