According to the evolutionary theory, how long ago did the earth form?
The earth formed 4.5 billion years ago.
Our entire solar system formed about 4.5 billion years ago. Prior to that it was a swirling mass of hot gas and tiny particulate matter. The sun first formed as it attracted most of the hydrogen existing in its general area.
Then the inner planets formed as hot particular matter started coalescing to one another, each forming its own pool of gravity and in turn attracting more particles. At first each of the 4 rocky planets were large balls of boiling matter.
The planets beyond Mars attracted the heavier gases existing, methane, ammonia, and other gases heavier than hydrogen and helium.