//
// 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級精確度時間
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.