gettimeofday(struct timeval *tv, struct timezone *tz)函数

gettimeofday(struct timeval *tv, struct timezone *tz)函数

功能:获取当前精确时间(Unix时间)

其中:

timeval为时间

truct timeval{
long tv_sec; // 秒数
long  tv_usec; // 微秒数
}

timezone为时区

 

#include<stdio.h>
#include<sys/time.h>
int main(){ 
struct timeval tv;
gettimeofday(&tv,NULL);
printf("%d,%d\n",tv.tv_sec,tv.tv_usec);
return 0;
}


 

 

posted @ 2013-07-20 18:33  坚固66  阅读(487)  评论(0编辑  收藏  举报