static std::string get_format_time(int64_t ms) {
int microsec = ms%1000;
time_t t(ms / 1000);
struct tm *p = localtime(&t);
char s[64];
int pos = strftime(s, sizeof(s), "%Y%m%d-%H:%M:%S", p);
sprintf(&s[pos], ".%03d", microsec);
return std::string(s);
}
static std::string get_curr_format_time() {
struct timeval tv;
gettimeofday(&tv, 0x0);
int microsec = tv.tv_usec/1000;
time_t t(tv.tv_sec);
struct tm *p = localtime(&t);
char s[64];
int pos = strftime(s, sizeof(s), "%Y%m%d-%H:%M:%S", p);
sprintf(&s[pos], ".%03d", microsec);
return std::string(s);
}
int main()
{
std::cout << get_format_time(1604992150091) << std::endl;
return 0;
}