No One knows when the Day of Resurrection will come except Allah
Here Allah tells His Messenger that he cannot know when the Hour will come, and if people ask him about that, He instructs him to refer the matter to Allah, may He be exalted, as Allah says in Surat Al-A`raf, even though that was revealed in Makkah and this Surah was revealed in Al-Madinah. Allah continues to tell him to refer this matter to the One Who knows about it, but He tells him that it is at hand, as He says:
Those hostile to Allah and the Messenger were warned of and alerted to curse and punishment in the present world and in the Hereafter while many factions among the disbelievers, in their own place, simply denied the eventuality of any Qiyamah (Doomsday) or 'Akhirah (Hereafter) and, because of their denial, used to mockingly ask: When would that Qiyamah come? An answer to their question has been given in the cited verse, that the Doomsday may be in near future. It has been said so because nobody knows the exact date of the Doomsday, and therefore everyone should be prepared for it as if it were very close. Another reason for its being declared as close is that after facing the horrible incidents of Qiyamah the entire worldly life of thousands of years will seem to be very short (and the Qiyamah very close to it).
Tazkirul Quran
Maulana Wahiduddin KhanOn ayahs 68–70
Enquiring about the exact day when the Day of Judgement would arrive did not mean that the enquiries had no belief whatsoever in Judgement Day. This was not meant to mock the Day of Judgement, but to ridicule the person who gave news of that Day. They did not deny that Judgement Day would actually come, but they did not believe in the nature of that Day, of which the Prophet and his companions gave specific details. Their real fault was that they gave undue importance to the leaders of their community, rather than showing due respect to the Prophet. That is why the words of the prominent persons of their community appeared to them more worthy of consideration than the words of the Prophet. But, on the Day of Judgement when the reality is revealed, they will regret that they could not differentiate between real greatness and false greatness, and that; having been deceived by false greatness, they went astray.
Uthmani text of the Madinah mushaf (King Fahd Complex). Translation: Saheeh International. Tafsir via Quran.com.