How the lunar calendar works
Each Islamic month follows the moon and lasts 29 or 30 days. A year of twelve months is therefore 354 or 355 days long. The Quran mentions twelve months in the year in the sight of Allah (Quran 9:36), and it says the moon is a way to know time (Quran 10:5).
A new month begins when the new crescent moon is seen, or in some places by calculation. The Prophet ﷺ said: "Fast when you see it and break your fast when you see it, and if it is hidden from you, complete Shaban as thirty days" (Sahih al-Bukhari 1909). He also explained that a month can have twenty-nine days (Sahih al-Bukhari 1907). A day in this calendar begins at sunset, not at midnight.
Many Muslims keep both calendars. They use the Gregorian calendar for daily life and the Hijri calendar for worship and for remembering Islamic events.