It actually takes the Earth 23 hours, 56 minutes and 4.06 seconds to make one rotation on its axis, not 24 hours. This is called a sidereal day, and is the amount of time that it takes the Earth to make a full rotation on its axis and end up in the same position relative to the stars. A solar day is the time it takes for the Earth to make one full rotation on its axis and end up in the same position relative to the Sun. Solar days are about four minutes longer than sidereal days because the Earth is simultaneously traveling about one degree around the Sun every day, so it has to rotate a bit more to compensate.
More about astronomy:
- It's also possible to measure a day in terms of the Earth's rotation relative to the moon. This is called a lunar day, and it lasts 24 hours and 48 minutes because the moon is continuously revolving around the Earth, so it takes the Earth longer time to come around to the same position relative to the moon.
- The other planets in the solar system, except Venus and Uranus, rotate the same way Earth does, which means that the Sun still appears to rise in the east and set in the west on those planets. Venus and Uranus rotate in the opposite direction, and in the case of Uranus, it appears to rotate sideways because its axis is almost flat.
- Some cultures use sidereal months, which last about 27 days, 7 hours, 43 minutes and 11.5 seconds. These are measured by the moon's rotation in relation to the stars, leading months to be divided into 27 or 28 "lunar mansions," also known as decans, manzils or nakshatras.