Skip to content

Instantly share code, notes, and snippets.

@Bingnan
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bingnan/833007071f7f5b3fb7e5 to your computer and use it in GitHub Desktop.
Save Bingnan/833007071f7f5b3fb7e5 to your computer and use it in GitHub Desktop.
获取unix系统时间,格式化输出的方法1
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