Because of the enormous gravity that there is in the centre of the Sun, this one reaches to fuse hydrogen atoms, creating, as a result, helium. This is named nuclear fusion. In the process, the fusions of atoms create a big quantity of energy, that to say, light, initially in the most energetic state of all: the gamma rays.
Normally it is said that the light from the Sun takes 8 minutes 20 seconds to reach the Earth’s surface, and these data are true, but the time that the light takes to go out of the Sun is much greater, in the order of the tens of thousands of years.
The journey of the light
Once the photons (which are the particles of the light) are emitted due to the nuclear fusion, these have to go across an enormous labyrinth before reaching the surface of the Sun, situated at 690 000 kilometres from its centre. This way is full of trillions and trillions of protons that interpose to the trajectory that follow the photons. In fact, protons interact with photons, and they make them ricochet, changing their trajectory randomly after each collision. In consequence, photons follow a random path.
The result of all these collisions is that light takes a lot of time before going out of the star.
The calculations to know how much time takes light in going out of the Sun are made using a mathematical model that simulates the Sun’s inside. This mathematical model has in mind the number of protons, their separation, the distance in which the light has to go through, and especially the density of each layer of the Sun (its nucleus is the densest part, and as we get away from it, the layers are each time less dense). The results of this simulation point out that photons are inside of the Sun about 170 000 years before arriving at the star’s surface. Even if here I talk about 170 000 years, other results indicate the thousands or tens of thousands of years.
Out of the Sun
At the moment in which the light emitted about 170 000 years ago, in the nucleus of the Sun, reaches the surface, it is free to travel through space. Without obstacles in its way, it arrives at the Earth after 8 minutes 19 seconds, after having gone through the 150 million kilometres that separate our planet from the Sun. However, it will do it having lost much of its initial energy. When it was emitted at the centre of the Sun it belonged to the gamma rays (the most energetic type of light), and when arriving at the Earth it is ultraviolet, visible or infrared light.
This video, made by TED-Ed, explains all these questions in a very didactic form and with very good animations: