Summary: I used to wonder why it was still warm at night (although often cooler) since the sun went down. At night, heat comes from the ground (which was heated by the sun during the day) because it radiates it up into the environment, some heat from the day is left over in the atmosphere and greenhouse gases keep it trapped in the atmosphere, and warm winds from other parts of the earth blow in.
The earth changes position relative to the sun and the result of that is another part of it receives sunlight. This means that the air in that area is warmed by the sun, especially the air lower to the ground, and some of that air can be transported via wind overseas and into other countries, helping to warm them at night, but that is not the only reason it is warm at night, the other reasons are below.
Greenhouses gases such as water vapour, carbon dioxide (CO2), and methane trap heat in the atmosphere received from the sun during the day by slowing the radiation of it into space during the day and night.
* Keep in mind that infrared radiation is heat.
Greenhouse gases achieve this because they are transparent (most gases are) and they are insulators. Transparent items, (not just gases, but liquids and solids) allow light to pass through them easily, but some of them, such as double-paned windows, carbon dioxide, methane, and water vapour, significantly inhibit infrared radiation/heat from passing through them, so they pass though very slowly. This is because they are insulators. This means that the earth’s atmosphere will store heat while it slowly radiates it into the atmosphere. There is not enough time during one night for all of it to be radiated, and of course, the sun comes back up the next day to heat it up again. Winter, on the other hand is a very prolonged period of decreased sunlight.
The surface of the earth (ground) acts as a large heat sink which absorbs heat from the sun during the day in the form of both visible and infrared light and re-radiates it as heat at night. Light is converted into heat when it is absorbed by a surface, such as the ground for example, and especially dark surfaces.
When the ground is covered in snow, much more light is reflected back into the atmosphere because snow is white, and hence more reflective than dirt which is dark brown.