Answer
Zul Karnain was a king who travelled extensively around the world and he put
up the wall to prevent the dangerous people- Yajuj and Majuj , from crossing
as they used to abuse the people. (Surah Kahf) We are not aware of the time
and era of Zul Karnain.
And Allah Ta’ala knows best
Mufti E. Desai