How do I get the current time on Linux in milliseconds? This is for the purpose of testing.
label1 .....
label2.
How do I get the current time on Linux in milliseconds? This is for the purpose of testing.
label1 .....
label2.
Use gettimeofday()
to get the time in seconds and microseconds. Combining and rounding to milliseconds is left as an exercise.
If you're looking for something to type into your command line, then Date +%H:%M:%S.%N
will give you the time with nanoseconds.
You have to do something like this ;-
struct timeval tv;
gettimeofday(&tv, NULL);
double time_in_mill =
(tv.tv_sec) / 1000 + (tv.tv_usec) * 1000 ; // convert tv_sec & tv_usec to millisecond