1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| #include <stdio.h>
#include <time.h>
// #include <sys/time.h>
int main()
{
// char *str = "Fri, 26 Feb 2021 02:22:08 GMT";
char *str = "2021-2-26 02:22:08";
struct tm time;
time_t tt;
strptime(str, "%Y-%m-%d %H:%M:%S", &time);
tt = mktime(&time);
printf("%lu\n", tt);
return 0;
}
|