It can be prayed anytime after midnight (Midnight is the exact half between sunset and sunrise). It is better and more preferable to pray during the last hours of the night and just before dawn so that one can stay awake and pray morning prayers before retiring.
Short Way of Praying Namaz al-Shab
There are a total of 11 rakaats in Namaz al-Shab.
Start with praying 8 rakaats i.e. 4 prayers of 2 rakaats each like the subh prayer to be prayed with the Niyat of
Salaat al-Shab. In both the rakaats recite Sura al-Hamd followed by any other Sura. Then recite 2 rakaats with the Niyyat of Salaat al-Shafa, which is to be prayed like the morning prayer. After that pray 1 rakaat Salaat with the Niyyat of Salaat al-Witr. It is prayed like the second rakaat of Salaat al-Subh. This one rakaat is the most important of the whole Salaat al-shab. Details of how to pray are described.
How To Pray Salaat al-Witr:
Take Tasbeeh in your hand and stand up. Make Niyyat of salaat al-witr, say Takbeer and recite Sura al-Hamd followed by Sura al-Qul-Huwallahu-Ahad three times then
Sura al-Qul-Audhu Bi-Rabbil Falaq and Sura al-Qul-Audhubi-Rabbin-Naas each once.
Then say Takbeer and raise your hands for Qunuut in which any Dua may be recited. It is preferable to recite the following Dua.
“Lailaha Illalahul Haleemul Kareem; Lailaha Illalaahul Aliyyul Adheem; Subhanallahi Rabbi-s-Samawaati-s-Sab’e, Wa Rabbil Aradheena-s-Sab’-e; Wamaa Feehinna Wamaa Baina-Hunna; Wa Rabbil Arshil Adheem; Wal Hamdulillahi Rabbil Aala Meen; Waswallalahu Alaa Muhammadin Wa Aalheit Twaahereen.”
Then hold the Tasbee in your right hand for counting and raise your left hand pray for 40 Momineen and Mominaat whether dead or alive in the following manner:
“Allahum-Maghfirli and the name of the Momineen or Mominaat”.
Then recite 100 times “Astagh-Firul-Laha Rabbi Wa Atuubu Ilayh”
Then recite 7 times: “Hadha Maqaamul Aaedheebeka Minan-Naar”.
After that recite 300 times. “Alafv”.
Finish the prayer in the usual way by going into Rukuu and Sajdah followed by Tashahud and Salaam. After finishing recite Tasbee al-Fatima Zehra A.S. Then make Sajda al-Shukr.