The Prophet did order us to pray 2 rakat Tahhiyatul Masjid before you sit when enter a mosque. What to do when entering the mosque in the 3 times it its prohibited to pray?
You don't pray tahyiyatul Masjid in the forbidden times. This includes at the sun's zenith, when it sets and when it rises. It also includes the times it is forbidden to pray optional prayers: after having prayed the sunnah of Fajr and after having prayed Fajr or Asr, and before Maghrib.