The intention for fasting should be made the night before dawn, if it is a compulsoryfast. However this (making intention the night before dawn) is not mandatory if the fasting is supererogatory. Thus it is permissible to make an intention for supererogatory fasting during the day, if one has not previously done anything

which nullifies fasting. This is in accordance with the hadith narrated by ‘Aishah, the mother of believers (may Allah be pleased with her): “ The Prophetﷺ entered one day and said: ‘Is there anything to eat?’ We answered that there was not. Upon that, he (the Prophet) said: ‘Hence, I am fasting.’”[ Source: Muslim.]source: islamkingdom