The day is the basic unit of time, in all timekeeping. Days may be grouped into weeks, months and years, or divided into hours and other subdivisions in various ways, and various times have been used for the start of the day (dawn, noon, dusk and midnight have all been in use at one time or another, including the present); but the daily rising and setting of the Sun, by establishing the overall length of a day (whether from sunrise to sunrise, sunset to sunset, noon to noon, etc), is the fundamental historical unit of time.
Subdividing the Day
Save for one glaring exception, days have been divided into twelve hours since Babylonian and Egyptian times. In Babylon, this was due to the Sumerian practice of counting by 5's and 12's, which was carried over. In Egypt, the days were divided into ten hours, but two hours of twilight (at dawn and dusk) made the total twelve, as well.
Nights were also divided into twelve hours, in most cases, making the 24 hours we are familiar with. But until the development of accurate timepieces in the 1600's, the hours of the day and night were not usually the more or less uniform hours we are used to. In the summer, the daylight hours were lengthened, and the nighttime hours shortened, and in the winter, the process was reversed, so that whether the Sun was up for a long time, or a short time, there were always twelve hours of day, and twelve hours of night. So if a farmer rose at dawn, it was always at the same time of day, regardless of the time of year.
The subdivision of hours into minutes, and minutes into seconds, goes back to the Babylonian system of counting by 60's (or 5 times 12). In fact, dividing units into sixtieths (partes minutae, in Latin; whence minutes) and sixtieths of sixtieths (partes minutae secundae, or seconds), and even sixtieths of sixtieths of sixtieths (partes minutae tertiae, or thirds) was carried out extensively, until the 1700's; but nowadays, only time and angular measurement retain this method of division, and only for minutes and seconds, thirds having been relegated to the dustbin of history. (This subdivision is still visible in angular units, where a whole degree is indicated by a small circle, representing a whole unit; a minute by a tick mark, representing the Roman numeral I, for first small parts; and a second by two tick marks, representing the Roman numeral II, for second small parts.)
And as for that glaring exception, after the French revolution, the French republic established a day consisting of ten hours, each of one thousand seconds, so that a day was exactly 100,000 seconds. Of course, the length of the day was the same in France as elsewhere, so during the few years that this "reform" lasted, French seconds were a little shorter than in other countries, and French hours were much longer.
Names of the Days
The names used in Western societies for the days of the week go back to Babylonian times, although they may not have been regularized into a pattern similar to the current one until Roman times. Each day was named for one of the planetary bodies known in ancient times -- the five naked-eye planets, and the Sun and Moon -- or for their associated gods and goddesses. These names are different in different languages and cultures, and there is, therefore, a considerable difference in the names of the days in various modern countries.
Sidereal and Solar Days
Astronomers distinguish between two different types of day -- sidereal days, measured by the rising and setting of the stars, and the more commonly used solar days, measured by the rising and setting of the Sun. As discussed in Rotation Period and Day Length, the difference between these is caused by the orbital motion of the Earth around the Sun, and the apparent motion of the Sun around the sky which results from our orbital motion. The difference is, that the sky (meaning the apparent globe of the stars) moves westward each sidereal day (24 sidereal hours), while the Sun moves westward each solar day (on the average, 24 solar hours, but varying slightly at different times of the year). The solar day is 3 minutes and 56 seconds longer than the sidereal day, which makes it 24 hours, 3 minutes, 56 seconds of sidereal time (3 minutes 56 seconds longer); and makes the sidereal day 23 hours, 56 minutes, 4 seconds of solar time (3 minutes 56 seconds shorter).
Apparent and Mean Time, and Standard Time
As noted above, the solar day only averages 24 hours length, being shorter on days when the Earth's orbital motion is slower, reducing the difference between the (nearly constant) sidereal day, and the solar day, and longer on days when the Earth's orbital motion is faster, increasing the difference between the sidereal and solar days. Because of this, time kept by a sundial, which relies on the actual position of the Sun in the sky, is not uniform, and differs from time kept by a uniform clock. To distinguish between the two times, we define the Apparent Sun as the position the Sun actually has in the sky, and the Mean Sun as the position the Sun would have if it moved along its apparent path (the Ecliptic) at an absolutely uniform rate (in other words, if the Earth's orbital motion was an absolutely uniform, circular motion). Apparent Solar Time is the time that would be kept by a sundial, using the position of the Apparent Sun, while Mean Solar Time is the time that would be kept by a sundial, using the position of the Mean Sun. Both times average 24 hours throughout the course of a year, but Mean Time is the same 24 hours every day, while Apparent Time varies by a few seconds. The difference between the two is given by the Equation of Time, and is often shown on globes by a strange-looking figure 8, called the analemma, which is usually placed off the west coast of South America on globes intended for the North American market.
(Discussion of the Equation of Time and the analemma? Diagrams needed, if do so)
The Apparent and Mean Solar Times discussed in the previous paragraph would be different at different locations, according to when the Sun rose and set, which is different for different longitudes, according to the rate at which the Earth turns on its axis. Since the Mean Solar Day is defined as 24 hours = 1440 minutes, and there are 360 degrees in a circle, the Earth rotates through a degree in 1440 / 360 = 4 minutes. This means that sundials at locations D degrees to the east of a given location would indicate a time 4D minutes ahead of sundials at that location, and sundials to the west of that location would indicate a time similarly behind the time at that location.
When travel and communication was difficult and slow, the difference in time kept by sundials at different locations was of little importance, but once rapid transportation became available, allowing every location to keep its own time was very inconvenient; and early in the age of railroads, laws were passed establishing uniform Time Zones which covered large areas, so that railroad time-keeping could be simplified. To distinguish uniform time from local time, Apparent and Mean Solar Times for a given location were called Local Apparent Solar Time and Local Mean Solar Time; and uniform times were referred to as such-and-such Standard Time, according to the local time zone. Still later, various "Daylight Savings" laws were enacted, leading to Standard Time and Daylight Time for each time zone, and oxymorons such as Local Apparent Standard Time (meaning Local Apparent Solar Time without taking Daylight Savings into account) and Local Apparent Daylight Time (adding an hour, under normal circumstances) are found in the text for my astronomy lab class.
Standard and Daylight Time, although they somewhat regularize time within a given area, still differ all over the Earth. For things which occur at the same local time, regardless of your location, such as when a particular star rises (which would be at different times at different longitudes, but at the same local time everywhere on a given parallel of latitude), there is no need to simplify (or complicate, depending upon your point of view) things any further. But for events which take place at a particular moment in time, it may be inconvenient to have to specify exactly when that is, for more than twenty different time zones. As a result, Universal Time (also called Coordinated Universal Time, or UTC) is used for such purposes. Universal Time is Local Mean Solar Time at a particular place on Earth, specified by international agreement as being on the Prime Meridian running through Greenwich, England (more exactly, through Airy's transit telescope, at the Royal Observatory in Greenwich, which is a suburb of London). It is not necessarily the actual time at Greenwich, as England observes Summer (Daylight) Time, and UT is the same as Standard Time for the Prime Meridian. Most astronomical tables intended for wide use indicate the UT of a given event, with additional notes providing conversion to local time zones, where the tables are sold.
Up to this point, all the complications have been due to the non-uniform motion of the Earth around its orbit, or the multitude of time zones required at different longitudes; but there is one additional complication that intrudes, if we compare times from different years; for it was discovered, in the late 1800's, that the Earth's rotation is not absolutely uniform, but gradually slowing at a rate of one or two thousandths of a second, each century. In other words, a century from now, the Earth will be rotating a thousandth or so of a second slower than now, and a century ago, it was rotating a thousandth or so of a second faster than now.
At first consideration, it might seem that this is hardly worth worrying about, as the change in any given year would be a hundred times smaller yet; but the error, though small, adds up, day after day after day, and in only a century a clock running at a constant rate would gain more than a minute on the gradually slowing rotation of the Earth; and as the centuries pile up, and the Earth slows more and more, the uniform clock would gain more and more time, until the results are startling.
It is possible to calculate the motion of the Earth around the Sun, and the Moon around the Earth, to a remarkable accuracy; and by combining the two, to calculate when eclipses of the Sun (or Moon) occurred (or will occur) over periods of thousands of years, to a fraction of a minute. Given that, we ought to be able to say, if the Earth always rotated the same, exactly where the Sun would be overhead, and the eclipses would be visible. But if we compare ancient records of solar eclipses to the calculations, we find that the further back in time we go, the greater the error in the calculation. Several thousand years ago, when the Earth was rotating only a twentieth of a second faster than now, eclipses took place nearly a third of the way around the Earth, from where we would predict them to have taken place. The small error, gradually growing, piling up over millions of days, has added up until the overall rotation of the Earth is now about 8 hours behind what it would have been, if the Earth were still rotating as it once was.
To take this effect into account, we define a time based on calculated positions of the Sun, Moon and planets, which is called Ephemeris Time, because a table listing those positions is called an ephermeris. Ephemeris Time is a uniform time, based on the average length of the day in 1900, so that in that year, the Mean Solar Day was exactly 24 hours = 1440 minutes = 86400 seconds. Tables showing the calculated positions of the planets, based on that uniform time, are presumably accurate predictions of where the stars and planets would be using an Ephemeris clock. But of course you are not likely to have such a clock. How can you determine where to look for something, at a given time, if your clock keeps Standard or Universal Time, and the tabular position is for Ephemeris Time? You look at a supplementary table, at the front of the tabulation, which gives the most recently calculated corrections for recent years, and the best estimate of what the correction will be, for this year.
The corrections listed in the supplementary table mentioned above gradually change, over the years, and sooner or later, if we were to use Ephemeris Time, the rotation of the sky would be noticeably different from the "movement" of our clocks. So we don't use Ephemeris Time, but Universal Time, which is based on the Mean Apparent Solar Time at the Prime Meridian, and is gradually slowing down, by the one or two thousandths of a second per century mentioned above. But if it is gradually slowing down, every now and then, it will get "off" from the "correct" time for the current position of the Earth, and we need to add some kind of correction. We could wait for a while, and add a minute, or add a few microseconds, every day; but the way we actually do it is, whenever the rotation of the Earth is more than a half-second away from the current Universal Time, we think about adding or subtracting a leap second. This can be done at any time, but traditionally, it is done on June 30, or December 31. If done on New Year's Eve, you would count down the year 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 0, the extra second being inserted just before the start of the New Year. Of course, no one does that, as most people have no need to keep track of the time to the nearest second; but whenever it is necessary to add (or subtract) a second from Universal Time, to keep proper track of the Earth's rotation to within that half-second accuracy, a bulletin is sent out to whoever cares to subscribe to it, so they can adjust any critical measurements which might depend upon it.