Jump to content
  • Advertisement
Sign in to follow this  
KontosHarry

Time....

This topic is 3690 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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!