How old was the earth when the layers formed?
Actually the layers of the earth were formed from the beginning of life on the Earth.
The major layers of the Earth,including the inner core,outer core,mantel,and the crust were formed as the building block of Earth known as planetesimals, collided and collapsed under their own gravity around 4.5 billion years ago. At that time the heavy elements sank to the core of the earth,while the lighter elements rose to form the crust and the mantel.
Thus giving birth to our planet 'Earth'.