5 string GetTimeStamp(tm * tm_local)
11 string date = to_string(tm_local->tm_year+1900) +
"-" + to_string(tm_local->tm_mon+1) +
"-" + to_string(tm_local->tm_mday);
17 string hour = to_string(tm_local->tm_hour);
18 if (hour.length() == 1) hour =
"0" + hour;
20 string min = to_string(tm_local->tm_min);
21 if (min.length() == 1) min =
"0" + min;
23 string sec = to_string(tm_local->tm_sec);
24 if (sec.length() == 1) sec =
"0" + sec;
26 string time = hour +
":" + min +
":" + sec;
27 string datetime = date +
" " + time;
40 time_now = time(NULL);
42 tm * tm_local = localtime(&time_now);
43 return GetTimeStamp(tm_local);