I am experimenting with ctime
but I can't, for the life of me, figure out how to print a date X days away from the current date. This is my program thus far:
#include "header.h"
int main()
{
time_t current;
struct tm * timedata;
time(¤t);
timedata = localtime(¤t);
cout << "The current date and time is: " << asctime(timedata) << endl << endl;
return 0;
}
If I'm correct, time(¤t)
returns the amount of seconds from January 1st, 2000, but the number I get seems too small for that to be it.. All help appreciated.
time(¤t) returns the number of seconds since Jan 1, 1970, UTC -0000.
Add n*86400, to get the time n days from/before the current time.
That assumes, of course, you won't cross the summer/winter time adjustment, if you happen to live in the part of the world that suffers from this bizarre concept...