Once a photon of light is generated, how long does it take to escape beyond the outer part of the Sun?
It takes thousands of years for a photon to get from the sun's core to escape from the surface.
When a photon is created in the core of the sun it will collide with many protons and electrons in its path to the surface.
The photon effectively has to find a path to the surface by randomly being absorbed and re-emitted by particles on the way. This is an example of the drunkard's walk problem.
The number of steps, between particles on the way
The time taken for each step is
This gives a total time
This calculation assumes that the free mean step is actually about a centimetre, it could be much smaller, which would make the time longer. In any case it takes thousands of years to make the journey.