READ GENESIS 47-50
God spoke to Abraham about his descendants, ‘Then the LORD said to him, “Know for certain that for four hundred years your descendants will be strangers in a country not their own and that they will be enslaved and mistreated there.’ Gen. 15:13
God had revealed some of the future to Abraham. Did Abraham mention this to Isaac, or Isaac to Jacob?
Then they said to Pharaoh, “We have come to live in the land for a time, because there is no pasture for the flocks of your servants, since the famine in the land of Canaan has been severe. So now, please allow your servants to settle in the land of Goshen.” Gen 47:4
The clock for the 400 years starts ticking from the time Abraham is told about being a stranger in a country not their own.
Answers in Genesis has a Table with a Timeline: