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);
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);