The knowledge of Ghayb is one of the attributes of Lordship, thus no one knows the Ghayb of Heaven and Earth except Allah;
Allah (may He be Exalted) says,
And with Him are the keys of the Ghayb (all that is hidden), none knows them but He. (Surah Al-An`am, 6: 59)
He (Great is His Majesty) also says,
Say: “None in the heavens and the earth knows the Ghayb (Unseen) except Allâh” (Surah Al-Naml, 27: 65)
The Jinn do not know the Ghayb, and this is proven in His Saying (may He be Exalted),
Then when We decreed death for him [Sulaimân (Solomon)], nothing informed them (jinn) of his death except a little worm of the earth which kept (slowly) gnawing away at his stick. So when he fell down, the jinn saw clearly that if they had known the Unseen, they would not have stayed in the humiliating torment. (Surah Saba’, 34: 14 )
Therefore, anyone who claims to know the Ghayb will be a Kafir (disbeliever) and anyone who believes in this claim will be a Kafir as well, for they will be denying the Qur’an.
May Allah grant us success! May peace and blessings be upon our Prophet Muhammad, his family and Companions!
Permanent Committee for Scholarly Research and Ifta’
The below is taken from Tafseer Ibn Kathir:
Allah tells us how Sulayman, peace be upon him, died and how Allah concealed his death from the Jinn who were subjugated to him to do hard labor. He remained leaning on his stick, which was his staff, as Ibn `Abbas may Allah be pleased with him, Mujahid, Al-Hasan, Qatadah and others said. He stayed like that for a long time, nearly a year. When a creature of the earth, which was a kind of worm, ate through the stick, it became weak and fell to the ground. Then it became apparent that he had died a long time before. It also became clear to Jinn and men alike that the Jinn do not know the Unseen as they (the Jinn) used to imagine and tried to deceive people.This is what Allah says:(nothing informed them (Jinn) of his death except a little worm of the earth which kept (slowly) gnawing away at his stick. So when he fell down, the Jinn saw clearly that if they had known the Unseen, they would not have stayed in the humiliating torment.) meaning, it became clear to the people that they (the Jinn) were lying.