A day is the name of several different units of time. It refers both to the period of light when the Sun is above the local horizon, as to the full day covering a dark and a light period. Different definitions of the day are mostly based on the apparent motion of the Sun across the sky (solar day). The reason for this apparent motion is the rotation of the Earth around its axis, as well as the revolution of the Earth in an orbit around the Sun.
Ancient custom has a new day start at either the rise or set of the Sun on the local horizon. The exact moment, and the interval beween two sunrises or two sunsets, depends on the geographical position (longitude as well as latitude), and the time of year.
A more constant day can be defined by the Sun passing through the local meridian, which happens at local noon (upper culmination) or midnight (lower culmination). The exact moment is dependent on the geographical longitude, and to a lesser extent on the time of the year. The length of a such a day is nearly constant. This is the time as indicated by sundials.
A further improvement defines a fictituous mean Sun that moves with constant speed over the equator; the speed is the same as the average speed of the real Sun, but this removes the variation over a year as the Earth runs its orbit around the Sun.
For civil purposes, since the middle of the 19th century when railroads with regular schedules came into use, a common clock time has been defined for an entire region based on the mean local solar time at some central meridian. For the whole world, about 30 such time zones are defined. The main one is "world time" or UTC (Coordinated Universal Time).
The present common convention has the civil day start at midnight, which is near the time of the lower culmination of the mean Sun on the central meridian of the timezone. A day is commonly divided into 24 hours of 60 minutes of 60 seconds each.
In astronomy also the sidereal day is used; it is ca. 3m56s shorter than the solar day, and close to the actual rotation period of the Earth.