//
// Created by zhenyumei. Mar, 14th, 2019.
//
#ifndef TIME_NOW_HPP
#define TIME_NOW_HPP
#include <glog/logging.h>
#include <stdio.h>
#include <sys/timeb.h>
#include <time.h>
#include <iostream>
struct NowTime {
char date[16];
char time[16];
char millsec[4];
};
NowTime getNowTime() {
NowTime now_time;
time_t timep;
time(&timep);
strftime(now_time.date, sizeof(now_time.date), "%Y-%m-%d-",
localtime(&timep));
strftime(now_time.time, sizeof(now_time.time), "%H-%M-%S-",
localtime(&timep));
struct timeb tb;
ftime(&tb);
sprintf(now_time.millsec, "%d", tb.millitm);
// LOG(INFO) << now_time.date << now_time.time << now_time.millsec;
return now_time;
}
#endif // TIME_NOW_HPP
c++ 得到ms级精确度时间
最新推荐文章于 2023-12-08 10:21:53 发布