What is the longest day of the year?
Most people think of June 21st as the longest day of the year. If you define a "day" to be the period of daylight during a 24-hour period, then they would be right. However, if we measure a day from noon to noon, the longest "solar" day of the year falls on December 22nd or 23rd.
Recall, that the earth revolves around the sun 360 degrees every 365 days. That's just under one degree per day. In addition, the earth rotates on its axis 360 degrees each 24-hour day. Therefore, from high noon on one day to high noon on the next, the earth must rotate almost 361 degrees to account for the earths revolution around the sun. And that is what the earth does, and that is how we define a 24-hour period.
However, the earth does not revolve around the sun in a perfect circle. Rather, it is an ellipse, and the sun is not at the center of the ellipse. Therefore, when the earth is closest to the sun (the perihelion of the ellipse), it moves faster around the sun than at any other time. And this means that the earth must spin further on its axis from high noon of one day to high noon of the next - more rotation takes more time. Therefore, the solar day is longer when the earth is closer to the sun - up to 8 seconds longer than the average day. Conversely, when the sun is the at the opposite end of the ellipse (the aphelion of the ellipse) the earth is moving its slowest and the solar days are shorter.
But wait, the tilt of the earth has an even bigger affect on the length of a day. When the earth is tilted away from its orbital path around the sun, it takes a greater rotation of the earth before the sun gets to its highest point in the sky, and when the earth is at its maximum angle of 23.5 degrees to its orbital path around the sun you have the greatest additional length of the solar day - 21 seconds longer than the average day.
It turns out that the earth is closest to the sun on January 4 of each year. And we all know that the winter solstice is sometime between December 20th and 23rd. These two factors work together to make December 22 or 23 the longest day of the year at 24 hours and 30 seconds.
So, what is the shortest solar day of the year?
September 17th or 18th.
What is the Equation of Time?
Here is a graph of a typical year vs. the length of the solar day (the vertical scale depends on the latitude).
Why is the latest sunrise before the winter solstice?
It isn't just one day in December that is longer than average. All the days are longer than average because the additional times of each day accumulate. Therefore, all times relative to the sun get pushed later. Therefore, the clock will indicate sunset before the sun sets. Therefore, the latest sunset is before the solstice and the earliest sunset is after the solstice. The actual date of each depends on the latitude. The latitudes closer to the poles will happen closer to the solstice and those closer to the equator will happen earlier than the solstice for the earliest sunset (and later than the solstice for the latest sunrise). For example, the earliest sunset in San Francisco in 2023 was on Dec 6. In Fairbanks, Alaska (closer to the pole) it was on Dec 18. And in San Diego (closer to the equator), it was on Dec 3.
For more info see: Sunrise sunset calendar (e.g., San Francisco) How the length of a day changes over the year Why December Has The Longest Days The earliest sunset comes before the winter solstice