hi, i'm a new user. and i got some question about the date...
is there any library function that can count the days of a date?
such as 1/1/2002 is 1st day of the year, then 1/2/2002 is the 32th days of the year ...
hi, i'm a new user. and i got some question about the date...
is there any library function that can count the days of a date?
such as 1/1/2002 is 1st day of the year, then 1/2/2002 is the 32th days of the year ...
Not that I know of, but it wouldn't be too hard to write either.
Code:int month, days, prevdays, year; //input all the information switch (month) { case 1: prevdays=0; break; case 2: prevdays=31 break; //do the rest of the months, don't forget to check if it's leap year } cout<<"Number of days passed is "<<prevdays+days;
icic....
it really help me a lot...
thank you !!!
Check all the other members of the tm structure for other neat measures of time.Code:#include <ctime> #include <iostream> int main(int argc, char* argv[]) { using namespace std; time_t currentTime = time(NULL); struct tm *timeInfo = localtime(¤tTime); cout << timeInfo->tm_yday; return 0; }