嵌入式 获取当前时间,并返回当前时间的秒数

  1. int print_current_time(void)
  2. {
  3. struct tm*tmnow;
  4. struct timevaltv;
  5. gettimeofday(&tv,NULL);
  6. tmnow = localtime(&tv.tv_sec);
  7. printf("d/d/dd:d:d:ld ",\
  8. tmnow->tm_year+1900, tmnow->tm_mon+1,tmnow->tm_mday,tmnow->tm_hour,\
  9. tmnow->tm_min, tmnow->tm_sec,tv.tv_usec);
  10. return tv.tv_sec;
  11. }

你可能感兴趣的:(嵌入式 获取当前时间,并返回当前时间的秒数)