A sundial functions by use of a raised piece of metal, called a gnomon, which sits in the middle of a marked dial. The gnomon casts shadows when lit by the sun, and the time of day is determined by where the shadow lands on the dial.
In order for a sundial to function properly, the gnomon needs to be aligned with the North Pole. One way to accomplish this is to use the North Star as a guide. A sundial may also need to be aligned differently depending on the latitude to account for varying angles of the sun in the sky.
Sundials were often used even after the invention of the mechanical clock. Early mechanical watches needed to be reset, and sundials were used to set the watches to an accurate time. The first sundials to use hours of equal length were invented by Muslims during the Middle Ages, and they were used to mark specific hours of prayer. Prior to this sundials displayed seasonal hours, which have a variable length depending upon the time of year.
Sundials were also used to keep track of the seasons. The ancient Greeks used a sundial known as a hemispherium which had a gnomon inside a hollowed-out bow. The size of the shadow inside a hemispherium helped timekeepers determine the exact time of year.