Over 100,000 years, then 8 minutes
A photon in the Sun's core bounces between atoms trillions of times in a random walk lasting 10,000 to 170,000 years. Once it escapes into space, it covers the 150 million km to Earth in just 8 minutes and 20 seconds.