C get milliseconds timestamp
from https://stackoverflow.com/questions/3756323/how-to-get-the-current-time-in-milliseconds-from-c-in-linux
#include <sys/time.h>
long current_timestamp()
{
struct timeval te;
gettimeofday(&te, NULL); // get current time
long long milliseconds = te.tv_sec*1000LL + te.tv_usec/1000; // caculate milliseconds
printf("milliseconds: %lld\n", milliseconds);
return milliseconds;
}
#include <sys/time.h>
long current_timestamp()
{
struct timeval te;
gettimeofday(&te, NULL); // get current time
long long milliseconds = te.tv_sec*1000LL + te.tv_usec/1000; // caculate milliseconds
printf("milliseconds: %lld\n", milliseconds);
return milliseconds;
}
留言
張貼留言