GetTime() Function?
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?
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.
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.
Here's how I do it:
--random
// 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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement