why do i get the data (realtime) in 1970-1-1 at 8.0.0 ?

sterretje:
That's not the start of the Unix timestamp (that should have been midnight). It looks like you pick up some rubbish from incorrect memory locations, maybe because tmpNow goes out of scope as soon as you leave the getTime function?

String getTime() {

time_t now = time(nullptr);
 struct tm* newtime = localtime(&now);

String tmpNow = "";
 ...
 ...
 return tmpNow;
}




Note
It's not advisable to use String (capital S); they can leave holes in your memory and as a result you might run out of memory resulting in difficult to find problems.

The function returns a copy of the tmpNow string, so that's not the problem.

I bet localtime() is applying a timezone offset of +8 hours.