Tutorial 13: Simple snippet C time_t to int
#include <stdio.h>
#include <time.h>
int main(){
struct tm tm;
time_t epoch;
if (strptime("2013-09-10 10:10:10", "%Y-%m-%d %H:%M:%S", &tm))
{
epoch = mktime(&tm);
printf("%d\n",(size_t)epoch);
}
else printf("error\n");
return 0;
}
Comments
Post a Comment