Are there any functions that return the current day month and year as integer.
Printable View
Are there any functions that return the current day month and year as integer.
OS? Compiler?
Have a look at the ctime functions here.
Note: for tm_mon, jan = 0, feb = 1, ..., dec = 11
Code:#include <iostream>
#include <ctime>
int main( void ) {
tm * curTM;
time_t temp = time( NULL );
curTM = localtime( &temp );
std::cout<<"Day: "<<curTM->tm_mday<<" Month: "<<curTM->tm_mon<<" Year: "<<curTM->tm_year + 1900<<std::endl;
return 0;
}
GetSystemTime() on windows is pretty good and easy. but then you still haven't said what platform you're on
Thx allot, XSquared. Works perfectly.
I was trying to mess around with time.h, but that
didn't lead anywhere. You just saved me about 2 hours of programming.