Last active
August 29, 2015 14:08
-
-
Save Bingnan/833007071f7f5b3fb7e5 to your computer and use it in GitHub Desktop.
获取unix系统时间,格式化输出的方法1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
time_t rawtime; | |
struct tm * timeinfo; | |
char buffer[80]; | |
time(&rawtime); | |
timeinfo = localtime (&rawtime); | |
strftime(buffer,80,"%F_%H-%M-%S",timeinfo); | |
LOG_INFO(g_logger, "AntTranscoder: strftime " + string(buffer)); | |
//------------------------------------------------------------------------ | |
struct tm* p = localtime(&process_start_time); | |
char ss[200]; | |
sprintf(ss, "%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d", (1900 + p->tm_year), (1 + p->tm_mon), p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec); | |
root["process_start_time"] = string(ss); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment