Advertisement Jump to content
Sign in to follow this  

GetTime() Function?

This topic is 4893 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

I am currently making a handy dandy calender that get's mad at me when it's time to do something. I can add date entities (BBall game at 7:00, 30 minute prep). I can modify them, and delete them. But I need to know the time... Anyone know of a standard time finding function not bound to any non standard or windows library?

Share this post

Link to post
Share on other sites
Take a look at the Standard C functions in time.h.

Though, in a c++ app make sure you #include <ctime> , not time.h
Take a look at the functions time() and localtime()

There's also boost::date_time, but you'll need to download boost, and it might be more than you need.

Share this post

Link to post
Share on other sites
Here's how I do it:

// I'm not sure if all these are needed.
#include <ctime>
#include <cstdlib>
#include <cstring>

using namespace std;

string timeString()
const int size = 20;
char buffer[size+1];
time_t t = time(0);
string timestring(buffer);
return timestring;


Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!