First, we would like to stress that the unseen or ghaib is defined as everything that cannot be perceived by man’s senses, including those things that remain secret from man and are only known by Allah the All-Aware, as well as those things that man has knowledge of due to his being informed of them by Allah and His Messenger (peace and blessings be upon him).

Dr. Ahmad Yusuf Sulaiman, professor of Shari`ah, Faculty of Darul-`Uloom, Cairo Univ., states the following: First of all, we would like to stress the fact that Allah Almighty is the Only One Who possesses the absolute Omniscience of the Unseen. This fact is explained by the Qur’an when it refers to the five main categories of the Unseen. Allah Almighty says: (Lo! Allah! With Him is knowledge of the Hour. He sendeth down the rain, and knoweth that which is in the wombs. No soul knoweth what it will earn tomorrow, and no soul knoweth in what land it will die. Lo! Allah is Knower, Aware.) (Luqman 31: 34)


Focusing more on the question in point, we would like to cite for you the following:
The issue of Prophet Muhammad (peace and blessings be upon him) having the ability to know the Unseen or `Ilm Al-Ghayb is a broad and lengthy subject that even Muslim scholars have divergent opinions about it. In brief, Prophet Muhammad (peace and blessings be upon him) has the ability to know only certain aspects of the Unseen that Allah wishes him and reveals to him.However, there are other aspects that Allah Almighty doesn’t show to the Prophet such as the date of the Day of Resurrection, Death, etc.