Sunan an Nasai 2117
The Book of Fasting
أَخْبَرَنَا مُؤَمَّلُ بْنُ هِشَامٍ، عَنْ إِسْمَاعِيلَ، عَنْ شُعْبَةَ، عَنْ مُحَمَّدِ بْنِ زِيَادٍ، عَنْ أَبِي هُرَيْرَةَ، قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم " صُومُوا لِرُؤْيَتِهِ وَأَفْطِرُوا لِرُؤْيَتِهِ فَإِنْ غُمَّ عَلَيْكُمُ الشَّهْرُ فَعُدُّوا ثَلاَثِينَ " .
It was narrated that Abu Hurairah said:"the Messenger of Allah said: 'Fast when you see it and stop fasting when you see it, and if it is obscured from you (too cloudy), then count it as thirty (days)
Grading: Abu Ghuddah: Sahih · Al-Albani: Sahih · Zubair Ali Zai: Sahih - Agreed Upon
Text from the public-domain hadith-api dataset. Numbering follows that dataset and can differ by a few from some printed editions — check the wording, not only the number.