时间戳c语言转换字符串,C语言 时间戳和标准格式的转换

intmain(intargc,char**argv)

{

time_tt;

t = time(NULL);

structtm*lt;

intii = time(&t);

printf("ii = %d\n", ii);

t = time(NULL);

lt = localtime(&t);

charnowtime[24];

memset(nowtime, 0,sizeof(nowtime));

strftime(nowtime, 24,"%Y-%m-%d %H:%M:%S", lt);

printf("nowtime = %s\n", nowtime);

return1;

}

int main(int argc, char **argv)

{

time_t t;

t = time(NULL);

struct tm *lt;

int ii = time(&t);

printf("ii = %d\n", ii);

t = time(NULL);

lt = localtime(&t);

char nowtime[24];

memset(nowtime, 0, sizeof(nowtime));

strftime(nowtime, 24, "%Y-%m-%d %H:%M:%S", lt);

printf("nowtime = %s\n", nowtime);

你可能感兴趣的:(时间戳c语言转换字符串)