As the Earth spins on its axis, the Sun always shines on one side giving us daylight. On the shaded side it is night time. As the Earth continues to turn, the shaded side move into the sun’s light, and the sunlit side turns away from the light. It takes 24 hours for the earth to make one complete turn on its axis and our clocks are based on this principle.
In the 1940s people discovered that the earth speeds up and slows down a little as it spins. We have now developed atomic clocks that can measure time exactly.