[关闭]
@zhengyuhong 2016-01-26T04:06:41.000000Z 字数 394 阅读 1205

sys/time.h

wiki


man gettimeofday

  1. struct timeval {
  2. time_t tv_sec; /* seconds */
  3. suseconds_t tv_usec; /* microseconds */
  4. };
  5. struct timezone {
  6. int tz_minuteswest; /* minutes west of Greenwich */
  7. int tz_dsttime; /* type of DST correction */
  8. };

exmaple

  1. #include <sys/time.h>
  2. int main() {
  3. struct timeval tv;
  4. gettimeofday(&tv, NULL);
  5. //tv保存时间的结构体,参数tz保存时区的结构体
  6. //函数获取当前时间距1970年1月1日(unix纪元日期)的时间,存储在tv中的tv.tv_sec(秒), tv.usec(微妙),不需要获取时区,传入NULL即可
  7. return 0;
  8. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注