The ozone layer along with atmospheric layer stores the heat of the sun for nights.
The surface of the earth holds heat, and the greenhouse gases in the atmosphere hold heat all through the night. If the earth had no atmosphere, then at night all the heat would escape out to space and the earth would be freezing.
Much of it is captured by the greenhouse gases, which hold the heat and prevent it escaping into space. As we add more and more greenhouse gases, they are able to hold more heat. This is how we are causing global warming.
The surface of the desert absorbs a great deal of solar radiation during the day. Since there is usually no cloud cover or humidity to hold this heat at night, the desert quickly radiates this heat back into space once the sun sets.
Much of it is captured by the greenhouse gases, which hold the heat and prevent it escaping into space. As we add more and more greenhouse gases, they are able to hold more heat. This is how we are causing global warming.
Clouds and high humidity act as a blanket to hold in heat at night. If these are absent, the heat absorbed by the earth during the day quickly radiates back into space.
The process by which gases hold heat in the air is called the greenhouse effect. Greenhouse gases in the atmosphere trap heat from the sun by absorbing and re-emitting infrared radiation. This process helps to keep Earth's temperature within a range that is habitable for life.
The Greenhouse Effect works by trapping heat in the Earth's atmosphere. Greenhouse gases like carbon dioxide and methane allow sunlight to enter the atmosphere and warm the Earth's surface. However, they also absorb and trap heat that would otherwise escape back into space, keeping the Earth warmer than it would be without them.
Earth's atmosphere is mainly heated from the ground up because the heat is absorbed into the ground. The warmed surface of the earth then emits heat as infrared radiation which rises into the atmosphere. There the greenhouse gases like water vapour, carbon dioxide and methane absorb and hold the heat.
Earth is farther from the sun than Mercury and Venus, and so recieves kess energy from the sun. Compared with Venus, Earth also has a lot less carbon dioxide in its atmosphere, so it does not hold heat as easily. Since Mercury has almost not atmosphere to hold in heat, the night side of the planet is actually extremely cold.
Planets have some heat.The Earth and other planets retain some residual heat left from the time planets and the Sun were formed four or five billion years ago. In addition, there are some internal sources of heat such as radioactive decay. Earth and other planets also gain heat from the Sun.Planets lose heat.Overwhelmingly, the mechanism for heat loss is through radiation of heat. All objects radiate heat in the form of electromagnetic radiation. (One can look up "black body radiation" which is an interesting topic in its own.) For Earth, this is typically characterized as infra-red radiation. The radiation is emitted from the Earth, through the atmosphere and heads out into cold space.(Space, all the apparent emptiness we see in the night sky, is at a temperature of about 4 degrees Celsius above absolute zero, compared to our temperature of almost 300 degrees above absolute zero. The cooling through radiation of the hot Earth is evident in our daily lives because the cooling we experience at night can be so dramatic. In particular, clouds prevent much infrared radiation from directly escaping. A cloudy night cools several degrees less than a clear night.)There are complications.Though there is no question that the Earth loses heat by radiating it into space, the details get complex. There are a lot of complications about how much energy of this sort is absorbed by the atmosphere and that leads to discussions of the Greenhouse Effect, but that can be left to another question. The greenhouse effect is quite real and part of the complex balance of energy incoming and energy radiated that can occupy a long discussion.
The desert is cold at night. This is because there are no clouds or trees to hold in the heat.
Mercury has essentially no atmosphere, which means that, while the day is extremely hot, it cannot hold onto that heat at night. Both day and night on Mercury are very long, with a single day-night cycle lasting 176 Earth days.