Skip to main content
gamedev.net
🔒 Locked

GetTime() Function?

Started by dbzprogrammer Aug 25, 2005 at 5:25 PM 1 replies 650+ views
Original Post
dbzprogrammer
dbzprogrammer
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?
We should do this the Microsoft way: "WAHOOOO!!! IT COMPILES! SHIP IT!"
Will F
Will F
Take a look at the Standard C functions in time.h.

Though, in a c++ app make sure you #include , 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.
random_thinker
random_thinker
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);      strftime(buffer,size,"%Y%m%d_%H%M%S",localtime(&t));      string timestring(buffer);      return timestring;}


--random
--random_thinkerAs Albert Einstein said: 'Imagination is more important than knowledge'. Of course, he also said: 'If I had only known, I would have been a locksmith'.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.