Answer:
The Earth rotates on it's axis, and it takes 24 hours for the Earth to go all the way around. When the part of the Earth you're on is facing the sun, you have daytime. When the part of the Earth you're on is not facing the sun (facing the moon instead), you have nighttime.
I hope this helps!