Abdullah ibn Umar (Allah be pleased with both of them) reported Allah's Messenger peace be upon him as saying:
The month (of Ramadan) may consist of twenty nine days; so when you see the new moon observe fast and when you see (the new moon again at the commencement of the month of Shawwal) then break It, and if the sky is cloudy for you, then calculate it (and complete thirty days).
Since each month could only consist of twenty-nine or thirty days, Muslims would go outside on the twenty-ninth day of Sha'ban (which is the 8th month in the calendar) after sunset to look for the new crescent in the sky. If the new moon crescent was seen by people sometime during the night, it would mean that the month of Sha'ban was twenty-nine days and now the month of Ramaḍan has entered. However, if it is not visible it means that the month of Sha'ban consists of thirty days and Ramaḍān will begin the following day.
The end of the month is determined in the same way by establishing that the new moon crescent is visible on the twenty-ninth of Ramadan after sunset. If it is then Ramaḍan will consist of only twenty-nine days and the following day is the month of Shawwal, which is Eid. However, if it is not visible it means that the month of Ramaḍan consists of thirty days and the month of Shawwal will begin the following day. INTERNET.