Hope this may be helpful. I am assuming a sketch is using c;
#include <time.h>
void main() {
time_t t;
struct tm *ptr_time;
char buffer[22];
// get the local time
time(&t);
// returns localtime to a tm structure
ptr_time = localtime(&t);
// converts time to a specific string
strfttime(buffer, 22, "%Y.%m.%d %H:%M:%S ", ptr_time);
printf("%s\n",buffer);
}