test.cpp
#include <iostream>
#include <stdio.h>
#include <sys/time.h>
#include <stdint.h>
using namespace std;
int64_t getCurrentTime()
{
struct timeval tv;
gettimeofday(&tv,NULL); //该函数在sys/time.h头文件中
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
int main()
{
int64_t time;
time = getCurrentTime();
cout<<"nowTime: "<<time<<endl;
return 0;
}
g++ -c test.cpp
g++ -o test test.o
./test
nowTime: 1565870866080