When Srimad Bhagvatam & Mahabharata were compiled?
Amongst mundane scholars, there is some diversity of opinion as to the date of compilation of Srimad-Bhagavatam. It is, however, certain from the text of the Bhagavatam that it was compiled before the disappearance of King Pariksit and after the departure of Lord Krishna. When Maharaja Pariksit was ruling the world as the King of Bharata-varsa, he chastised the personality of Kali. According to revealed scriptures and astrological calculation, the age of Kali is in its five thousandth year. Therefore, Srimad-Bhagavatam was compiled not less than five thousand years ago. Mahabharata was compiled before Srimad-Bhagavatam, and the Puranas were compiled before Mahabharata. That is an estimation of the date of compilation of the different Vedic literatures. Badarayana (Vyasadeva) a powerful incarnation of Narayana, broadcasted the Vedic wisdom to the world. As such, Vyasadeva is offered respects before one chant the Vedic literature, especially the Puranas. Sukadeva Gosvami was his son, and rsis like Vaisampayana were his disciples for different branches of the Vedas. He is the author of the great epic Mahabharata and the great transcendental literature Bhagavatam. The Brahma-sutras–the Vedanta-sutras, or Badarayana-sutras–were compiled by him. Amongst sages, he is the most respected author by dint of severe penances. When he wanted to record the great epic Mahabharata for the welfare of all people in the age of Kali, he was feeling the necessity of a powerful writer who could take up his dictation. By the order of Brahmaji, Sri Ganeshji took up the charge of noting down the dictation on the condition that Vyasadeva would not stop dictation for a moment. The Mahabharata was thus compiled by the joint endeavor of Vyasa and Ganeshji. The Mahabharata was compiled by Vyasadeva after the Battle of Kurukshetra and after the death of all the heroes of Mahabharata. It was first spoken in the royal assembly of Maharaja Janamejaya, the son of Maharaja Pariksit.
Source: A.C. Bhaktivedanta Swami Prabhupada (2014 edition), “Srimad Bhagavatam”, First Canto, Chapter 7 – Text 8
A.C. Bhaktivedanta Swami Prabhupada (2014 edition), “Srimad Bhagavatam”, First Canto, Chapter 9 – Text 6 & 7