An Islamic month does not have a fixed number of days. Rather each month can be 29 or 30 days long, depending on the moonsighting.
عَنْ عَبْدِ اللَّهِ بْنِ عُمَرَ رَضِيَ اللَّهُ عَنْهُمَا، أَنَّ رَسُولَ اللَّهِ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ، قَالَ: الشَّهْرُ تِسْعٌ وَعِشْرُونَ لَيْلَةً، فَلاَ تَصُومُوا حَتَّى تَرَوْهُ، فَإِنْ غُمَّ عَلَيْكُمْ فَأَكْمِلُوا العِدَّةَ ثَلاَثِينَ
(Sayidina) Abdullah bin Umar (May Allah Most High be pleased with them both) narrated that the Messenger of Allah ﷺ said, ‘A month is twenty-nine nights. Do not fast until you see it (the crescent moon). However, if it is not visible to you, then complete thirty days (as Sha’ban).’ (Sahih al-Bukhari, 1907).
As opposed to the Gregorian calendar used in much of the world today, the Islamic calendar does not have a predetermined number of days for every month. Rather each month can be 29 or 30 days long in the Islamic calendar, depending on the moonsighting.
After the 29th day, Muslims are required to go out in the evening and attempt to sight the moon. If the moon is sighted then the next day is the 1st of the new month. If it is not sighted then the next day will be the 30th of the current month, and the day after that will be the 1st of the new month. This is how we determine how long an Islamic month is, based upon the Sunnah of our beloved Prophet ﷺ, as seen in the Hadith above.
حَتَّى تَرَوُا الْهِلَالَ ” أَيْ حَتَّى يَثْبُتَ عِنْدَكُمْ رُؤْيَةُ هِلَالِ رَمَضَانَ بِشَهَادَةِ عَدْلَيْنِ أَوْ أَكْثَرَ، وَيَثْبُتُ بِعَدْلٍ وَاحِدٍ عِنْدَ أَبِي حَنِيفَةَ أَيْضًا، إِذَا كَانَ فِي السَّمَاءِ غَيْمٌ. (مرقاة المفاتيح شرح مشكاة المصابيح)
Until you see the crescent moon. Meaning until the Ramadan moonsighting has been established for you, with the testimony of two or more upright people. (Imam) Abu Hanifah established it with the testimony of one upright person too, if there is cloud in the sky. (Imam Ali al-Qari, Mirqaat al-Mafateeh).
Not only must the moon be sighted, but the sighting must be scrutinised by a Muslim judge (Qadi). The judge must decide whether the person claiming to have sighted the moon is upright or not. After such scrutiny, if the judge declares the moonsighting to be valid then it must be accepted by all Muslims (according to the opinion of global sighting).
The determination of the moon being sighted or not has to be based on observation and not calculation. Therefore, astronomical calculations play no role in affirming or denying a moonsighting. See the links below for details.
And Allah Most High Knows Best.
-Answered by Shaykh Noorud-deen Rashid (27.04.2022)
Can astronomical calculations be used for moonsighting?
Hadith prohibiting calculations for moonsighting Sahih?
See also video: