Set up current date & time of txt file in SD card

Each time that I create a txt file in SD card with an Arduino UNO, always put the same date (01/01/2000) & time (1:00 am).
How can I set up the current date & time to the txt file each time that I create with Arduino UNO?.

Thanks you.

1 Like
void sdTimeCallback(uint16_t* date, uint16_t* time) {
 *date = FAT_DATE(year(), month(), day());
 *time = FAT_TIME(hour(), minute(), second());
}

I use the TimeLib for time

in setup

 if (SD.begin(SD_SS_PIN)) {
   SdFile::dateTimeCallback(sdTimeCallback);
   Serial.println(F("SD card initialized"));
 }
1 Like

Thanks Juraj.

Very kind and very quickly your response.

sarriaga35:
Thanks Juraj.

Very kind and very quickly your response.

you are welcome. I use it in my project.