Thursday, May 24, 2007
get milliseconds time
Q; how to get milliseconds time
A:
ON linux/unix/etc
You may try the "gettimeofday" function. It reports the time down to microsecond level. The function is included via "".
#include
long milliseconds;
struct timeval currenttime;
gettimeofday(¤ttime, NULL),
milliseconds = (currenttime.tv_sec)*1000+(currenttime.tv_usec)/1000;
ON WINDOWS
Code: ( text )
#include "windows.h"
FILETIME now;
GetSystemTimeAsFileTime(&now);
or if you want it split in to hours etc
Code: ( text )
#include "windows.h"
SYSTEMTIME now;
GetSystemTime(&now);
A:
ON linux/unix/etc
You may try the "gettimeofday" function. It reports the time down to microsecond level. The function is included via "
#include
long milliseconds;
struct timeval currenttime;
gettimeofday(¤ttime, NULL),
milliseconds = (currenttime.tv_sec)*1000+(currenttime.tv_usec)/1000;
ON WINDOWS
Code: ( text )
#include "windows.h"
FILETIME now;
GetSystemTimeAsFileTime(&now);
or if you want it split in to hours etc
Code: ( text )
#include "windows.h"
SYSTEMTIME now;
GetSystemTime(&now);
Labels: time work
Subscribe to Posts [Atom]
Scrape It |