Around 2500 BC. Michael Coogan and Cynthia Chapman wrote a textbook on the Old Testament. They say the digs at Ai show a city destroyed around 2500 BC. That is long before Joshua, whom most scholars place at the end of the 1200s BC. The name Ai means "the ruin". A study Bible, the New Oxford Annotated Bible, says the site was uninhabited in the Late Bronze Age, the period when the book's events are usually placed.
Coogan and Chapman read the Ai story as an etiology, an origin tale told to explain something people could see: a great mound of ruins and a heap of stones at the old gate. On their reading it answers two questions, how the ruins got there and how Ai got its name. They think the tale probably stood on its own first and was tied to Joshua only later.
Learn the Bible.
Not just the stories, but the history, authorship, and scholarship behind it.