Did the Prophet Muhammad (PBUH) have Ilme Ghayb (knowledge of the Unseen)?

Allah (SWT) has the absolute knowledge about everything, and He grants part of the knowledge to whom He wants (Ayatul Kursi, Sura Bqara). Elm Ghayb is absolutely with Allah (SWT) and He grants parts of it to the Prophet (SAWA) and to the Infallible Imams and even to other very pious servants of Allah (SWT).

The Prophet (SAWA) and Imam Ali (a.s) had informed about many facts unknown to people ,and it is mentioned in many Sunni and Shia books, which proves that they had knowledge of the unseen up to the extent that Allah (SWT) has granted them.