Psalm 104:19 (ESV)

19 He made the moon to mark the seasons; the sun knows its time for setting.

In Psalm 104:19–23, it is about the creation of the moon and the sun, to regulate the time (of day). What is emphasized here is that it is God who has done this (see Genesis 1:14–18).

The moon, as well as the sun, are not independent forces as was thought by many nations in the time that the Psalms were written. Therefore, it is not fitting that man would worship these heavenly lights. These imposing heavenly lights also have, as duty, to radiate God’s greatness.

As it says, for example, in Psalm 19:1–6, The heavens declare the glory of God, and the sky above proclaims his handiwork…. In them he has set a tent for the sun…. Its rising is from the end of the heavens, and its circuit to the end of them, and there is nothing hidden from its heat.

Incidentally, it was the phases of the moon that determined the calendar in those days. In that time, people measured time with moon-months. Every following month was connected to the rising of the new moon.