How do bats distinguish between day and night? Do they hunt at night - if yes, how they know that?
Are they afraid of sunlight?
Bats distinguish day and night the same way that other animals do, with an internal circadian clock and by environmental cues (dawn and dusk).
Most bats (over 1000 different species total) are nocturnal, meaning that they are out of their roost and foraging at night. This includes that vast majority of bats, which also echolocate. Some bats, notably pteropodid "Flying foxes" are diurnal, meaning they are active during the day and sleep at night, like humans. These bats are typically fruit-eating. There are, of course, exceptions, but these general patterns hold.
Bat Conservation International has good educational information about bats.
Mammals have what are called intrinsically photosensitive retinal ganglion cells (ipRGCs) (Wikipedia), including bats (ref). These cells are responsible for modulating mammals circadian rhythms (differently for diurnal and nocturnal species). These cells are interesting because retinal ganglion cells are not normally photosensitive, but receive high acuity images from rods and cones. Interestingly, people with cone-rod retinal dystrophy (including those with complete blindness) still have their circadian rhythms set by ipRGCs in the retina, because these cells are spared. This was unfortunately demonstrated by a doctor that removed the eyes of someone who was blind, which resulted in the patient being unable to have a regular sleep cycle (citation needed).
Hence, even though bats (may?) have poor eyesight, ipRGCs in their retina still set their circadian rhythms. I don't believe they are afraid of the sunlight per se, but the sunlight makes them sleepy. They typically use echolocation at night.