Day by day, it shall be revealed, as it is written in the words of our teacher Moses (Exodus 34:28): "And he was there with the Lord forty days and forty nights." Is it not also written (Habakkuk 3:4), "And His brightness was as the light"? (Daniel 2:22) "And He gives wisdom unto the wise." (Psalm 139:12) "Yea, the darkness hideth not from Thee." But how did Moses know when it was day and when it was night, so that he could say "forty days and forty nights"?
When God was teaching him the Torah, he knew it was day, and when He was teaching him the Mishnah, he knew it was night. Another explanation is that whenever the angels praised God in holiness, he knew it was day, and when he saw them praising Him with "Blessed be," he knew it was night. Another explanation is that when he saw the angels playing with the manna, and they came down to Israel, he knew it was day, and when it came down to them, he knew it was night.
Another explanation is that when he saw the sun going down and bowing, he knew it was night, and when he saw the stars, the moon, and the constellations coming out and bowing down before God, he knew it was day, as it is said (Nehemiah 9:6) "And the host of heaven worshippeth Thee." Another explanation is that when he heard the Shema being recited before the prayers, he knew it was day, and when the prayers were recited before the Shema, he knew it was night.
Rabbi Pinchas said in the name of Rabbi Abba that the angel in charge of prayer waits until the last synagogue in Israel has prayed, and then he makes a crown and puts it on the head of God, as it is said (Proverbs 10:6), "Blessings are upon the head of the righteous." The righteous one of the world.