add FormatDateTime

This commit is contained in:
aozhiwei 2018-11-17 16:37:33 +08:00
parent 98259b5f2c
commit e62be6c99f
2 changed files with 11 additions and 0 deletions

View File

@ -153,4 +153,14 @@ namespace a8
return std::string(buf);
}
std::string FormatDateTime(time_t time_val)
{
struct tm tm_time = {0};
localtime_r(&time_val, &tm_time);
char buff[256];
buff[0] = '\0';
strftime(buff, a8::ArraySize(buff), "%F %T", &tm_time);
return std::string(buff);
}
}

View File

@ -63,6 +63,7 @@ namespace a8
bool MkDir(const std::string& path);
void ForceCreateDir(const std::string& path);
std::string GetIpAddress(unsigned long ip_saddr);
std::string FormatDateTime(time_t time_val);
}