Photosynthesis not just happens on plants, but also on algea and lots of bacteria. Here we only talk about the photosynthesis on plants. Plants use photosynthesis to make the useless carbondioxide into useful organic compounds (such as sugar) for their own use. Photosynthesis, just like what the prefix of the word itself says, light (the prefix photo- means light ) is essential. Photosynthesis contains light reaction and dark reaction, and only the light reaction requires light. In other words, light reaction must happen in the day, and dark reaction can happen either in the day or at night because light is not necessary.
So what does photosynthesis needs besides light and dioxide? Well, water is also necessary. If you know chemistry, the formula of all types of sugar contains hydrogen, and for plants the only possible source to attain hydrogen to form sugar is water. Carbon dioxide (CO2) is attained from the extremely small holes on the leaves called stomata, water is attained from the root system obviously, and light is attained from the chlorophyll, something green located at the chloroplast.
In the light reaction, sunlight is converted to ATP and NADPH. Chlorophyll utilizes the sunlight to produce enough ATP, NADPH for the latter dark reaction, and the side produc of the light reaction also includes oxygen gas (O2), and is released through the stomata, the same small holes where the carbon dioxide gets in. In the dark reaction (light is not necessary here), ATP and NADPH helps to convert carbon dioxide into sugar, and this process in known as the carbon fixation process, and it's also called the Calvin-Benson Cycle. In this process, carbon dioxide is combined with a 5-carbon sugar, so a 6-carbon sugar will form. The 6-carbon sugar then decompose into one glucose and one fructose, then the glucose along with fructose makes the sugar for the plant's own use.