On the fourth day of creation after the earth was made.

Genesis 1.16

16 And God made two great lights; the greater light to rule the day, and the lesser light to rule the night: he made the stars also.

Before the earth was made.

Job 38.7

When the morning stars sang together, and all the sons of God shouted for joy?