头文件
#include <time.h>
#include <stdio.h>
函数接口
void printTime(){
//time utils
time_t tt;
struct timeval tv_;
struct tm *timeinfo;
long tv_ms =0,tv_us=0;
char output[20];
time(&tt);
timeinfo = localtime(&tt);
gettimeofday(&tv_,NULL);
strftime(output, 20,"%Y-%m-%d %H:%M:%S",timeinfo);
tv_ms=tv_.tv_usec/1000;
tv_us=tv_.tv_usec%1000;
printf("time is :%s %ld:%ld\r\n",output, tv_ms,tv_us);
}
···
网友评论