Year problem
Topic last updated
31 Oct 2010, by
Wim De Roeve.
2 replies
Hi,
I'm having problems with decoding the month and year...
today Sun Oct 31 19:15:01 2010, gives as result da:31,mo:9,ye:110
tm * timeinfo;
ctTime = time(NULL);
timeinfo = localtime(&ctTime);
da=timeinfo->tm_mday;
mo=timeinfo->tm_mon;
ye=timeinfo->tm_year;
Anybody a solution?
Replies
#
31 Oct 2010 . Edited: 31 Oct 2010
hi
->tm_year is years since 1900
so try
ye=timeinfo->tm_year + 1900;
see here
Matt
year is based on 1900 "epoch". Just add 1900 to tm_year to get correct year, i.e. 110+1900 = 2010.
Please log in to post a reply.
Hi,
I'm having problems with decoding the month and year...
today Sun Oct 31 19:15:01 2010, gives as result da:31,mo:9,ye:110
tm * timeinfo;
ctTime = time(NULL);
timeinfo = localtime(&ctTime);
da=timeinfo->tm_mday;
mo=timeinfo->tm_mon;
ye=timeinfo->tm_year;
Anybody a solution?