"); //-->
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
#include <string.h>
int main(int argc ,char *argv[])
{
char buf[32] = {0};
struct timeval tv;
struct tm tm;
size_t len = 28;
memset(&tv, 0, sizeof(tv));
memset(&tm, 0, sizeof(tm));
gettimeofday(&tv, NULL);
localtime_r(&tv.tv_sec, &tm);
strftime(buf, len, "%Y-%m-%d %H:%M:%S", &tm);
len = strlen(buf);
sprintf(buf + len, ".%-6.3d", (int)(tv.tv_usec/1000));
printf("%s\n", buf);
return 0;
}(1条消息) linux打印一个精确到毫秒级的时间_u013206135的专栏-CSDN博客_linux打印时间毫秒
*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。