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;
}
时间: 2024-10-13 10:52:09