On the moon, that would be when the sun is not in the sky on the part of the moon you are standing on.
The Earth rotates around its own axis once every twenty-four hours. The Moon, on the other hand, rotatesonce around its own axis every 28 days, and once around the Earth in that same 28 days. The end result of this combination is that the same side of the Moon is always facing the Earth.