And the Prophet Muhammad (peace and blessings be upon him) said: As long as a person waits for the prayer, he is counted as being in prayer. It is the waiting for the prayer that keeps him detained in the mosque.
Hadith Referenceمسند احمد / مسند المكثرين من الصحابة / 8246