According to Genesis 1 we read:
Genesis 1:1-5
1 In the beginning God created the heaven and the earth.
2 And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.
3 And God said, Let there be light: and there was light.
4 And God saw the light, that it was good: and God divided the light from the darkness.
5 And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.
According to verse 1 we read that God created the heaven and the earth in the beginning. Then in verse 2-3 darkness was upon the earth and then light was introduced upon the earth. In verse 4 God divided the light from the darkness. Could this mean that he caused the earth to rotate? At this time the earth began to have day and night. The first of these cycles was called the first day.
Notice that the light came upon the earth after the earth was formed. Thus days and nights were not reckoned until God divided the light from the darkness. Thus what we know as the first day was not when the earth was created. It was created before the light was upon the earth. It was created in what God calls the "Beginning". It was not created within the first seven days as recorded in Genesis 1.
Also Notice the events of the 4th day.
Genesis 1:14-19
14 And God said, Let there be lights in the firmament of the heaven to divide the day from the night; and let them be for signs, and for seasons, and for days, and years:
15 And let them be for lights in the firmament of the heaven to give light upon the earth: and it was so.
16 And God made two great lights; the greater light to rule the day, and the lesser light to rule the night: he made the stars also.
17 And God set them in the firmament of the heaven to give light upon the earth,
18 And to rule over the day and over the night, and to divide the light from the darkness: and God saw that it was good.
19 And the evening and the morning were the fourth day.
On the 4th day God placed other sources of light to serve as the day and night. I believe this to be the Sun, Moon, and Stars. So what was the source of light that was in the first day of creation? In the New Testament we read:
2 Peter 3:8
8 But, beloved, be not ignorant of this one thing, that one day is with the Lord as a thousand years, and a thousand years as one day.
Latter-day revelation has brought us the following:
Abraham 3:2-4
2 And I saw the stars, that they were very great, and that one of them was nearest unto the throne of God; and there were many great ones which were near unto it;
3 And the Lord said unto me: These are the governing ones; and the name of the great one is Kolob, because it is near unto me, for I am the Lord thy God: I have set this one to govern all those which belong to the same order as that upon which thou standest.
4 And the Lord said unto me, by the Urim and Thummim, that Kolob was after the manner of the Lord, according to its times and seasons in the revolutions thereof; that one revolution was a day unto the Lord, after his manner of reckoning, it being one thousand years according to the time appointed unto that whereon thou standest. This is the reckoning of the Lord’s time, according to the reckoning of Kolob.
Abraham 5:13
13 But of the tree of knowledge of good and evil, thou shalt not eat of it; for in the time that thou eatest thereof, thou shalt surely die. Now I, Abraham, saw that it was after the Lord’s time, which was after the time of Kolob; for as yet the Gods had not appointed unto Adam his reckoning.
According to the above, The Lord's time (or one day to the Lord) is equal to 1000 years of our time. Adam was not given his reckoning of time when he was commanded not to partake of the tree of knowledge of good and evil. This command occurred after the 7 days of creation in Genesis 1. Thus the 7 days of creation were after the Lord's time which is 1000 years of our time for each day. Thus the 7 days were 7000 years. Evidently the light mentioned in Genesis 3-4 was likely from the star Kolob.
So the earth was created before the 7000 year periods of creation. The temporal existence of the earth will also be 7000 years. The earth will rest on its Sabbath for 1000 years beginning at the Lord's second coming. Thus the earth is more than approximately 13000 years old. But we do not know how long before the seven creation periods the earth was created.