Question: in which yuga did ramayana happen?
Answer: According to the 'Yuga System' of Hinduism, Ramayana occurred in Treta Yuga while Mahabharata took place in Dwapara Yuga, several years after the Treta Yuga. So there are several instances that prove that Ramayana took place before Mahabharata but Ramayana was written much after the Mahabharata.