方法一
time_t seconds;
seconds = time((time_t *)NULL);/获取秒
打印seconds如下
1104556407
1104556408
1104556409
1104556410
1104556411
方法二:
time_t now;
struct tm *tm_now;
time(&now);
tm_now = localtime(&now);
tm的范围就是0~60。
方法三打印当前时间
time_t t;
struct tm *p;
t=time(NULL);
p=localtime(&t);
printf("%s\n", asctime(p));
方法四:
struct timeval tv;
gettimeofday(&tv, NULL);
printf("tv_sec: %d\n", tv.tv_sec);
printf("tv_usec: %d\n", tv.tv_usec);