The Messenger of Allah ﷺ said, "Fast when you see it and break your fast when you see it. If the month is obscured from you by clouds, then count thirty days."
أخبرنا مؤمل بن هشام عن إسمعيل عن شعبة عن محمد بن زياد
قال رسول الله ﷺ صوموا لرؤيته وأفطروا لرؤيته فإن غم عليكم الشهر فعدوا ثلاثين
Bukhari narrated it in the Book of Fasting, in the chapter "The statement of the Prophet ﷺ, 'When you see the crescent moon, fast, and when you see it, break your fast,'" hadith no. 1909, and Muslim narrated it in the Book of Fasting, in the chapter on the obligation of fasting Ramadan upon sighting the crescent moon, etc., hadith no. 19/1081, from the hadith of Shubah with this wording. It is also found in Al-Kubra, hadith no. 2427.* Ismail is Ibn Ulaya.