There are 2 opinions regarding this. It was the practice of Rasool Allah صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ to wake up and ask if food was available and if it wasn't he would decide he was going to fast. Niyyah/intention should be before Fajr arrives, however for voluntary fasting the rulings are different.
Shaykh Yahya Ibrahim answers and explains...
No transcription found