A plant is nature's battery. During the day, they use the energy from sunlight to combine carbon dioxide and water into carbohydrates and oxygen is a byproduct. They burn the carbohydrates with oxygen to produce the energy they need, but in sunlight they produce more than they consume. At night they use oxygen and produce carbon dioxide.
At night, the photosynthesis stops but the respiration continues burning the carbohydartes as they use oxygen and produce carbon dioxide.
(Not a correction, just added for clarification)