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);

Labels:


Comments: Post a Comment

Subscribe to Post Comments [Atom]





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]

Scrape It
Free Hit Counters
Scrape It