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, then count thirty days."
قال رسول الله ﷺ: صوموا لرؤيته وأفطروا لرؤيته، فإن غمي عليكم الشهر فعدوا ثلاثين.
Bukhari narrated it in the Book of Fasting (1909), and Muslim in the Book of Fasting (1081:19), both through the route of Shubah, who said, Muhammad bin Ziyad narrated to us, saying, I heard Abu Hurairah say (and then he mentioned the hadith), and the wording given is that of Muslim.Bukhari's wording is, "But if it is obscured from you, then complete Shaban as thirty days." This is how it appears in the copy before us, and the Hafiz [Ibn Hajar] noted that it is likewise found this way in the narration of Sarakhsi, who vocalized it with a fatha on the dotted ghayn and a light (unshaddaded) ba. Regarding "ghubbiya," he said, "As for 'ughmiya,' 'ghumma,' and 'ghummiya' (with the mim either doubled or light), all of these carry the same meaning, that of being obscured. As for 'ghubbiya,' it is derived from ghabawah, meaning lack of perceptiveness, and this is used metaphorically for the concealment of the new moon. Ibn Arabi reported that it was also narrated as 'umiya,' with the plain ayn, from al-ama (blindness). He said, this carries the same meaning, since it refers to the loss of sight regarding things observed, or the loss of insight regarding things comprehended by the intellect." End of quote from Fath [Bari] (4/124).