You'll want to give yourself about two hours to get back to the airport and go through security so a layover of six hours only leaves you with about three hours of exploring. For more time to haggle in the souq or have a leisurely meal, 8-10 hours is even better.