Linux time总结

timegm:

man timegm:  相当于将环境变量设置为UTC,调用mktime转换为time_t。即把输入作为UTC时间处理。

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

int main(int argc, char* argv[])
{
time_t cur_t;
struct tm tm_seek;
time_t tmt_seek = 0;

time(&cur_t);
printf("time:%d",cur_t);
char timestr[19]="[20160101T01:01:01Z";
strptime(timestr, "%Y%m%dT%H%M%S.", &tm_seek);
tmt_seek = timegm(&tm_seek);
printf("time:%d",tmt_seek);
return 0;
}

 

posted @ 2016-08-22 19:26  Hi!gc  阅读(369)  评论(0编辑  收藏  举报