Answer:

But, beloved, do not forget this one thing, that with the Lord one day is as a thousand years, and a thousand years as one day. (2 PETER 3:8).

GENESIS 1:1, ISAIAH 46:9-10, MICAH 5:2-4, PSALM 115:3

You know, Trent, the Bible tells us that God is outside of time—to Him a day is like a thousand years, and a thousand years are like a day. He therefore knows everything before it happens. He even created time. He is not bound by time, and He sees all of life and history from start to finish at the same time! In other words, He sees the end from the beginning. He sees what is past and what is still to come. The Bible confirms this through the prophets (people in the Bible who told about things that hadn’t happened yet). God used these people to let others know some of the things that were going to happen. One example is the Prophet Micah who wrote about Jesus being born long before it happened. 

Today, God still knows exactly what is going on. He is always doing what pleases Him, and what is best for us, and He knows all things before they happen! He is truly a great and wonderful God, deserving of our worship and praise!

Source: https://answersingenesis.org/kids/creation/how-does-god-know-something-before-it-happens/