• Advertisement
Sign in to follow this  

Time....

This topic is 3389 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hallo How can I take the time in C++ sth about _strtime but I want to add and count the seconds in an "short seconds;" seconds = x; Which is the x??

Share this post


Link to post
Share on other sites
Advertisement
I use a function from the following book:

MUD GAME PROGRAMMING
By Ron Penton


// returns the miliseconds transcurred

// Windows gets the time since the system was started
// Linux gets the time since 1970

sint64 GetTimeMS() {
#ifdef WIN32
sint64 t;
QueryPerformanceCounter( (LARGE_INTEGER*)(&t) );
return t / g_win32counter.m_frequency;
#else
struct timeval t;
sint64 s;
gettimeofday( &t, 0 );
s = t.tv_sec;
s *= 1000;
s += (t.tv_usec / 1000);
return s;
#endif
}


And for Seconds you can use:


sint64 GetTimeS() {
return GetTimeMS() / 1000;
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement