Mahlzeit is a German salutation. It is the short form of a more formal salutation, "Gesegnete Mahlzeit" (archaic term, de: Blessed mealtime). The salutation is commonly used without connection to food or eating in Northern Germany, and this usage, corresponding to something like "hello, everyone" or "I'm off, folks", is becoming more and more widespread in informal settings, such as between office co-workers. In Austria it is used as a salutation during meal times. Similarly, in most German regions it is only used in connection with meals.
Mahlzeit can also be used in a negative sense. For example, when two people see something that might well spoil their appetite, one may sarcastically say "Mahlzeit" (or the stronger, "Na, Mahlzeit!") to the other.
When greeted with "Mahlzeit", one would ordinarily reply with "Mahlzeit" in return, or simply with "Danke", the German term for "thank you".