The Messenger of Allah ﷺ said, or Abu Qasim, peace and blessings be upon him, said, "Fast when you sight it and break your fast when you sight it. If it is obscured from you, then count thirty days."
حدثنا حجاج قال حدثنا شعبة عن محمد بن زياد قال سمعت
قال رسول الله ﷺ أو قال أبو القاسم عليه الصلاة والسلام صوموا لرؤيته وأفطروا لرؤيته فإن غم عليكم فعدوا ثلاثين
Its isnad is sahih, and the hadith has occurred many times before, see 1931, 1985, 9346, 9426, 9520, 9521, and it will come again at 10017, 10399, 16064, 18797.