The Messenger of Allah ﷺ said, "When you see the crescent, begin fasting, and when you see it again, break your fast. If it is hidden from you by clouds, complete Shaban as thirty days, unless you see the crescent before that. Then fast Ramadan for thirty days, unless you see the crescent before that."
أخبرنا محمد بن حاتم قال حدثنا حبان قال حدثنا عبد الله عن الحجاج بن أرطاة عن منصور
قال رسول الله ﷺ إذا رأيتم الهلال فصوموا وإذا رأيتموه فأفطروا فإن غم عليكم فأتموا شعبان ثلاثين إلا أن تروا الهلال قبل ذلك ثم صوموا رمضان ثلاثين إلا أن تروا الهلال قبل ذلك
[Sahih] See the two preceding hadiths. It is in Kubra, no. 2438. Abdullah is Ibn Mubarak, and Habban is bin Musa, and Muhammad bin Hatim is bin Nuaym Marwazi.