1 #include<stdio.h>
2 #include<time.h>
3
4 int main()
5 {
6
7 int seconds = 0;
8 seconds = time(NULL);
9
10 time_t t;
11 t = time(NULL);
12
13 printf("now second is:%d\n",seconds);
14 printf("time_t is:%ld\n",t);
15 struct tm * loctime = localtime(&t);
16 printf("now hour is:%d\n",loctime->tm_hour);
17 printf(" now day is:%d\n",loctime->tm_mday); // 本月第几天
18
19 return 0;
20
21 }
2 #include<time.h>
3
4 int main()
5 {
6
7 int seconds = 0;
8 seconds = time(NULL);
9
10 time_t t;
11 t = time(NULL);
12
13 printf("now second is:%d\n",seconds);
14 printf("time_t is:%ld\n",t);
15 struct tm * loctime = localtime(&t);
16 printf("now hour is:%d\n",loctime->tm_hour);
17 printf(" now day is:%d\n",loctime->tm_mday); // 本月第几天
18
19 return 0;
20
21 }