We know today that all it takes to have a day-night cycle is a rotating Earth and light coming from one direction. The Bible tells us clearly that God created light on the first day, as well as the Earth.
Thus we can deduce that the Earth was already rotating in space relative to this created light. God can, of course, create light without a secondary source. We are told that in the new heavens and Earth there will be no need for sun or moon Rev 21:23. In Genesis, God even defines a day and a night in terms of light or its absence.