"I said: 'O Messenger of Allah! Which mosque was built first?' He said: 'Al-Masjid Al-Haram (in Makkah).' I said: 'Then which?' He said: 'then Al-Masjid Al-Aqsa (in Jerusalem).' I said: 'How many years between them?' He said: 'Forty years, but the whole earth is a mosque for you, so pray wherever you are when the time for prayer comes.'" (Using translation from Ibn Mājah 753)
سَأَلْتُ رَسُولَ اللهِ ﷺ أَيُّ مَسْجِدٍ وُضِعَ فِي الْأَرْضِ أَوَّلُ؟ قَالَ الْمَسْجِدُ الْحَرَامُ قُلْتُ ثُمَّ أَيٌّ؟ قَالَ ثُمَّ الْمَسْجِدُ الْأَقْصَى قُلْتُ كَمْ بَيْنَهُمَا؟ قَالَ أَرْبَعُونَ سَنَةً قُلْتُثُمَّ أَيٌّ؟ قَالَ ثُمَّ حَيْثُمَا أَدْرَكْتَ الصَّلَاةَ فَصَلِّ فَكُلُّهَا مَسْجِدٌ