This excerpt is taken from Sheikh Muhammad Farooq's book Issues of the Two Eids.
The Shariah Method for Determining Eid al-Fitr :.
Eid al-Fitr is celebrated on the first of Shawwal, and the method of determining it is that if the moon of Shawwal is sighted after the twenty-ninth of Ramadan, then Eid is on that day; otherwise, if the thirty days of Ramadan are completed, Eid will be the next day. This is because the Islamic month is either twenty-nine or thirty days, and after counting thirty days, the next month inevitably begins.
➊ Abu Huraira (may Allah be pleased with him) narrates that the Messenger of Allah (peace be upon him) said:
صوموا لرؤيته و أفطرو لرؤيته، فإن غمى عليكم الشهر فعدوا ثلاثين
"Fast when you see the moon and break your fast when you see the moon (i.e., observe Eid al-Fitr). If the sky is cloudy and you cannot determine the month, then count the month as thirty days."
Reference: Sahih Bukhari, Book of Fasting, Chapter: The Prophet's Saying: When you see the crescent, fast: 1909. Sahih Muslim, Book of Fasting, Chapter: Obligation of fasting Ramadan upon sighting the crescent: 1081 - Sunan Nasa'i: 2119. Musnad Ahmad: 415/2
➋ Abdullah bin Umar (may Allah be pleased with him) states that the Messenger of Allah (peace be upon him) mentioned Ramadan and said:
لا تصوموا حتى تروا الهلال ولا تفطروا حتى تروه، فإن غم عليكم فاقدروا له
"Do not fast until you see the crescent of Ramadan, and do not break your fast until you see the crescent. If the sky is cloudy, then estimate the month."
Reference: Sahih Bukhari, Book of Fasting, Chapter: The Prophet's Saying: When you see the crescent, fast: 1906 - Muslim, Book of Fasting, Chapter: Obligation of fasting Ramadan upon sighting the crescent: 1080 - Sunan Nasa'i: 2123, Musnad Ahmad: 6322
➌ Abdullah bin Amr (may Allah be pleased with him) narrates that the Messenger of Allah (peace be upon him) said:
الشهر تسع وعشرون، فإذا رأيتم الهلال فصوموا، وإذا رايتموه فأفطروا ، فإن غم عليكم فاقدرواله
"The month is twenty-nine days, so when you see the crescent of Ramadan, fast, and when you see the crescent of Shawwal, break your fast. If the sky is cloudy, then estimate the month."
Reference: Sahih Bukhari, Book of Fasting, Chapter: The Prophet's Saying: When you see the crescent, fast: 1907 - Muslim, Book of Fasting, Chapter: Obligation of fasting Ramadan upon sighting the crescent: 1080 - Sunan Abu Dawood, Book of Fasting, Chapter: The month is twenty-nine days: 2320
Benefits:
The aforementioned hadiths are evidence that the method for determining the fasting days of Ramadan and the Eid al-Fitr is the sighting of the crescent of Ramadan and Eid. Otherwise, the determination of Ramadan and Shawwal will be made after completing thirty days of the month.