Days are longest in the summer for the northern hemisphere due to tilt of the Earth's axis allowing for more sunlight to be projected onto surface. Longest day of the year is at the summer solstice For opposite reasons, days are short and nights long in the winter. The seasons are caused by the angle the sun's rays make with the ground. Higher Sun angle means more luminosity per square meter. Low Sun angle produces fewer rays per square meter.
More intensity means more heat and, therefore, higher temperatures.
Note that, due to the fact that our oceans store heat, the actual changes in mean Earth temperature are delayed by several weeks, i.e. the hottest days of summer are usually in late July, over a month from the summer solstice. This motion was first recorded by Hipparchus in 100 B.C. who noticed differences between ancient Babylonian observations and his own. When the Pyramids were built, the north star was Vega. Typical we use synodic time, which means with respect to the Sun, in our everyday life. Astronomers often use sidereal time, which means time with respect to the stars, for their measurements.