edv:prg:cpp:example:aktuellen_timestamp_erfassen
Aktuellen Timestamp erfassen
Als Beispiel eine Funktion, die die aktuelle Zeit erfaßt und über Parameter formatiert zurück gibt:
void getCurrentDateAndTime (string& currentDate, string& currentTime) { time_t now_global = time(0); // aktuelle Zeit ermitteln tm ltm; tm now_local; localtime_s(<m, &now); localtime_s(&now_local, &now_global); char date[11]; // Im Format: "2015-12-31" sprintf_s(date, "%04i-%02i-%02i", now_local.tm_year + 1900, now_local.tm_mon, now_local.tm_mday); currentDate = date; char time[12]; // Im Format: "23-59-59-00" sprintf_s(time, "%02i-%02i-%02i-%02i", now_local.tm_hour, now_local.tm_min, now_local.tm_sec, 0); currentTime = time; } // getCurrentDateAndTime()
Hier sind weitere Infos zu den Zeit-Funktionen zu finden.
Stand: 05.07.2016
— : Jürgen Kreick
EOF
edv/prg/cpp/example/aktuellen_timestamp_erfassen.txt · Zuletzt geändert: 2020/01/11 01:23 von 127.0.0.1