Get time in milliseconds on Windows and Linux
In Microsoft Windows you can call directly this API:
GetTickCount();
This call, based to MSDN documentation, return the number of milliseconds that have elapsed since the system was started, up to 49.7 days.
In Linux you can use this ready-made function:
#include <sys/time.h> unsigned long GetMillisecondsTime() { struct timeval tv; if(gettimeofday(&tv, NULL) != 0) return 0; return (unsigned long)((tv.tv_sec * 1000ul) + (tv.tv_usec / 1000ul)); }
This function return the number of milliseconds elapsed since Epoch.
Comments
Post a Comment