It is necessary for the one who fasts to make the intention before Fajr
It is narrated from Hafsah (may Allah be pleased with her) that the Prophet ﷺ said:
من لم يجمع الصيام قبل الفجر فلا صيام له
“Whoever does not make a firm intention before Fajr (that is, the true dawn), has no fast.”
[صحيح: صحيح أبو داود: 2143 ، كتاب الصوم: باب النية فى الصيام ، أبو داود: 2454 ، ترمذي: 830]
This hadith is also proof of this: إنما الأعمال بالنيات “Actions are judged by intentions.”
[بخاري: 1 ، كتاب بدء الوحى]