c++中如何将unix时间戳转换为标准时间,有函数吗

如题所述

第1个回答  推荐于2016-04-16
C/C++ code

#include <stdio.h>
#include <time.h>

int main(void)
{
time_t tick;
struct tm tm;
char s[100];

tick = time(NULL);
tm = *localtime(&tick);
strftime(s, sizeof(s), "%Y-%m-%d %H:%M:%S", &tm);
printf("%d: %s\n", (int)tick, s);

return 0;
}本回答被提问者和网友采纳
相似回答