struct timespec tout;
struct tm *tmp;
char buf[64];
clock_gettime(CLOCK_REALTIME, &tout);
tmp = localtime(&tout.tv_sec);
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tmp);
printf("current time is %s\n", buf);
11-11
2万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-08
4172
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-06
1214
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)