Sahih Muslim , Book 13, Hadith 23 (In-Book)

Abu Huraira (Allah be pleased with him) narrated that the Messenger of Allah (may peace he upon him) made a mention of the new moon and (in this connection) said: Observe fast when you see it (the new moon) and break fast when you see it (the new moon of Shawwal), but when (the actual position of the month is) concealed from you (on account of cloudy sky), then count thirty days.

حَدَّثَنَا أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ، حَدَّثَنَا مُحَمَّدُ بْنُ بِشْرٍ الْعَبْدِيُّ، حَدَّثَنَا عُبَيْدُ اللَّهِ بْنُ، عُمَرَ عَنْ أَبِي الزِّنَادِ، عَنِ الأَعْرَجِ، عَنْ أَبِي هُرَيْرَةَ، - رضى الله عنه - قَالَ ذَكَرَ رَسُولُ اللَّهِ صلى الله عليه وسلم الْهِلاَلَ فَقَالَ ‏ "‏ إِذَا رَأَيْتُمُوهُ فَصُومُوا وَإِذَا رَأَيْتُمُوهُ فَأَفْطِرُوا فَإِنْ أُغْمِيَ عَلَيْكُمْ فَعُدُّوا ثَلاَثِينَ ‏" ‏ ‏.‏

sunnah.com