The Messenger of Allah ﷺ does not know when the Hour will be
Allah commands His Messenger to say to the people that he has no knowledge of when the Hour will be and he does not know whether its time is near or far.
(Say: "I know not whether which you are promised is near or whether my Lord will appoint for it a distant term.") meaning, a long period of time. In this noble Ayah is an evidence that the Hadith that many of the ignorant people often circulate, which says that the Prophet will not remain under the earth more than one thousand years (i.e., the Hour will be before that period) is a baseless lie. We have not seen it in any of the Books (of Hadith). Verily, the Messenger of Allah ﷺ was asked about the time of the Hour and he would not respond. When Jibril appeared to him in the form of a bedouin Arab, one of the questions he asked the Prophet was, "O Muhammad! Tell me about the Hour" So the Prophet replied,
Verse [ 26] is the proof of the preceding verse. The Holy Prophet ﷺ does not know whether the promised day is close or whether a longer time is appointed for it, because Allah alone is the knower of the Unseen. That is His exclusive characteristics, and therefore He does not divulge His Unseen to anyone. The definite article alif lam in al-ghaib 'the Unseen' is grammatically referred to as alif lam for istighraq lil jins 'the article encompassing and indicating the entire genus' [ as stated in Ruh with reference to Radi, that is, He is Omniscient - knowing every species of the Unseen and all genera of the Unseen. In the idafah [ possessive case ] construction ghaibihi 'His Unseen', the possessive pronoun refers to 'Allah' and reinforces His predominance over the Unseen. Allah's knowledge comprehends and encompasses every infima species [ species of species ] and every summum genus [ genus of genera ] of His creation. This is a specialized attribute of Allah. He does not divulge His Unseen to anyone indiscriminately, so that he may store and retrieve the secrets of the unknown world as and when he wishes.
The purport of the verse under comment is to affirm the totality of Allah's knowledge of the Unseen so that He alone is fully aware of every particle of His creation, and to negate such total knowledge of the Unseen for anyone other than Allah. It was possible that an unintelligent person might surmise that the Holy Prophet ﷺ did not have any knowledge of the Unseen - so, how can he be a Messenger? Allah reveals to a Messenger thousands of secrets of the Unseen. Anyone to whom no revelation comes down cannot be a Prophet or a Messenger. Thus the following verse makes an exception:
(...except a messenger whom He chooses [ to inform through revelation ], and then He appoints [ angels as ] watching guards before him and behind him, [ so that devils may not tamper with the divine revelation,].... 72:27)
Tazkirul Quran
Maulana Wahiduddin KhanOn ayahs 23–27
The entire system of the present world has been formulated with the aim of putting human beings to the test. Therefore reality is revealed here solely to the extent of conveying the divine message. Had there been no human trial to be considered, and had the concealing veils been removed, the people would have seen that, from the angels to the righteous among the jinn, all acknowledge the god-head of God and the whole universe testifies to this.
Uthmani text of the Madinah mushaf (King Fahd Complex). Translation: Saheeh International. Tafsir via Quran.com.