No one has an exact date pinpointed but archaeologists have narrowed it down to two parts. It was either written around the time of the Trojan war or it was written three to five hundred years later. The evidence is slim to back up both theories but scientists have been looking at the timeline and pulling facts together.
The first part of the second question is that both works of literature were written around the time of the Trojan War. Historians believe this because both works were based of the events of the Trojan War, so wouldn’t it be smart to say that Homer got the events down as they were happening? The pieces of literature would be as accurate as it could get. There isn’t really any evidence that supports this theory. It’s just guesses and dates on a timeline.
The second part is that the Iliad and the Odyssey were both written three to five hundred years after the Trojan war. Historians believe this because Homer was a Dorian and when they invaded Greece, they couldn’t read or write. The Trojan War happened around a hundred years after the Dorians came into town and that is not enough time to learn to be literate. Homer would’ve came into the picture hundreds of years later, learned about the Trojan War and created the pieces out of history. Hopefully one of these days we’ll find out if Homer was the real author and the correct time it was